Home > Backend Development > PHP Tutorial > php怎么取的指定id的值

php怎么取的指定id的值

WBOY
Release: 2016-06-13 10:02:07
Original
1393 people have browsed it

php如何取的指定id的值啊
php如何取的指定id的值啊 
如:
$sql="select * from customers where customers_id=".$_GET["id"];
$result=mysql_query($sql,$conn) or
die("error:".mysql_error);

$num=mysql_num_rows($result);
if ($num >0) {
 ....这里如何写啊 ,如果有相同的值 是不是就出来两个啊 我只要第一个

}
?>

------解决方案--------------------

PHP code
if($num>0){$row = mysql_fetch_assoc($result); print_r($row);}<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
$sql="select * from customers where customers_id=".$_GET["id"];$result=mysql_query($sql,$conn) ordie("error:".mysql_error);$num=mysql_num_rows($result);if ($num >0) {mysql_fetch_array($result); }?><br><font color="#e78608">------解决方案--------------------</font><br>$result=mysql_query($sql,$conn)<br>你得到结果集??<br>你是想从多个行中取第一个行吧??<br>$rows=mysql_fetch_row($result)<br>这就是一行了,如果有多行,默认为第一行!<br><font color="#e78608">------解决方案--------------------</font><br>总感觉你这么写SQL语句有问题<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨
php如何取的指定id的值啊
如:
$sql="select * from customers where customers_id=".$_GET["id"];
$result=mysql_query($sql,$conn) or
die("error:".mysql_error);

$num=mysql_num_rows($result);
if ($num >0) {
....这里如何写啊 ,如果有相同的值 是不是就出来两个啊 我只要第一个

}
?>


------解决方案--------------------
id 如果是自动生成的就不会有重复的吧
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template