[英]Showing multiple results in search engine
I've a bug in a search engine showing results. 我在搜索引擎中看到一个错误,无法显示结果。 Here's the code:
这是代码:
$nmanufacturer = $tApplication[2];
$manufac = mysql_query("SELECT * FROM tManufacturers WHERE nManufacturer='$nmanufacturer'");
$manufacts = mysql_fetch_array($manufac);
//nom du constructeur
$contruct = $manufacts[1];
?>
<select class="form-control">
<option><?php echo $contruct; ?></option>
</select>
The probleme is that the option element shows only one result however there's many results in the database 问题在于,option元素仅显示一个结果,但是数据库中有很多结果
Hope you can Help Me Guys! 希望你能帮助我!
Bon jour! 你好! You have to do a while cicle.
您必须做一会儿冰柱。
$nmanufacturer = $tApplication[2];
$manufac = mysql_query("SELECT * FROM tManufacturers WHERE Manufacturer='$nmanufacturer'");
?>
<select class="form-control">
<?php
while($manufact = mysql_fetch_array($manufac)) {
echo '<option>' . $manufact[1] . '</option>';
}
?>
</select>
The mysql_fetch_array function returns an associative array, but it also returns FALSE if there are no more rows to return! mysql_fetch_array函数返回一个关联数组,但如果没有更多行要返回,它也会返回FALSE! Using a PHP While Loop we can use this information to our advantage.
使用PHP While循环,我们可以利用这些信息来发挥我们的优势。
If we place the statement "$row = mysql_fetch_array()" as our while loop's conditional statement we will accomplish two things: 如果将语句“ $ row = mysql_fetch_array()”作为while循环的条件语句,我们将完成两件事:
via http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php 通过http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.