为何表单中的select的值传不过来?

l_kk 2002-04-17 10:32:29
在main.php程序中有如下代码:
<form name="form1" method="post" action="delete.php">
<p>删除新闻
<select name="select">
<?
while(OCIFetchInto($stmt, &$result)&&$result[0]!='') {
echo "<option value='.$result[0].'>".$result[0]."</option>";
}
?>
</select>
<input type="submit" name="Submit" value="提交">
</p>

在delete.php中的代码如下:
<? $conn = OCILogon("system", "manager", "");//连接数据库
if (!$conn) {
echo "<h1>ERROR - 连接数据库失败</h1>";
exit;
}
//读取记录
$sql="select flag from newstype where type_name='$select' ";
$stmt = ociparse($conn,$sql);//分析sql语句
if (!$stmt){
echo "<h1> error count not parse sql statment!</h1>";
exit;
}
ociexecute($stmt);//执行
ocifetchinto($stmt,&$result);
echo $result;
exit;?>

请问为何没有返回值?
...全文
168 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
fbib1540_cn 2002-04-17
  • 打赏
  • 举报
回复
我觉得应该是这样
<select name="select">
<?
while(OCIFetchInto($stmt, &$result)&&$result[0]!='') {
echo "<option value=\"$result[0]\">".$result[0]."</option>";
}
?>
</select>
你试一试看看行不行
rosen 2002-04-17
  • 打赏
  • 举报
回复
关注中... ...
l_kk 2002-04-17
  • 打赏
  • 举报
回复
to rosen:这样做也不行。


在原来的main.php中select的值是静态的,例如:
<select name="select">
<option>新闻1</option>
<option>新闻2</option>
</select>
---这样做的话是成功的。

而不是象现在那样:---
<select name="select">
<?
while(OCIFetchInto($stmt, &$result)&&$result[0]!='') {
echo "<option value='.$result[0].'>".$result[0]."</option>";
}
?>
</select>
我想问题是出在这儿的。
wylyf 2002-04-17
  • 打赏
  • 举报
回复
先在你的DELETE。PHP中看看 是否可以显示SELECT的值
如果能显示说明你的SQL语句处理错误!
rosen 2002-04-17
  • 打赏
  • 举报
回复
用printf看看: (不保证正确)

printf("<option value='.$result[0].'>".$result[0]."</option>");
rosen 2002-04-17
  • 打赏
  • 举报
回复
在delete.php中,能 echo $select 吗?
l_kk 2002-04-17
  • 打赏
  • 举报
回复
好的,谢谢。
qiushuiwuhen 2002-04-17
  • 打赏
  • 举报
回复
最好 变量和字符串分离

echo "<option value=".$result[0].">".$result[0]."</option>";
l_kk 2002-04-17
  • 打赏
  • 举报
回复
:)谢谢fbib1540_cn()。 成功了!!!

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧