[英]No result from options selected from a database column (php-mysql)
In the PHP code below i want to select all the column values of a table and make them options of a select form. 在下面的PHP代码中,我想选择表的所有列值,并使它们成为选择表单的选项。 The result is that i dont get any options at all.
结果是我根本没有任何选择。 Could someone help?
有人可以帮忙吗? Thanks
谢谢
<?php
// ....
$userid=$_SESSION['userid'];
echo "<select>";
$sql = "SELECT * FROM users where userid='".$userid."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "<option>" .$row['company']. "</option>";
}
echo "</select>";
mysqli_close();
?>
It may just be a typo but you have mixed mysql and mysqli functions, you have stated mysql_query and mysql_fetch_array, whereas you have closed it with mysqli_close, could be an issue depending on what you wrote above this code or indeed if this is not just a typo. 可能只是拼写错误,但您混合使用了mysql和mysqli函数,已经声明了mysql_query和mysql_fetch_array,而使用mysqli_close将其关闭,则可能是一个问题,具体取决于您在这段代码上写的内容,或者实际上这是否仅仅是一个错误。错字。
Other things to try would be try the query in your mysql client / phpmyadmin and see if it comes up with any results or errors. 其他可以尝试的方法是尝试在mysql客户端/ phpmyadmin中查询查询,看看它是否有任何结果或错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.