Jump to content

same line diffrent in sql and php


asmith

Recommended Posts


<?php
$conn = mysql_connect("localhost","john","abc");
mysql_select_db("test",$conn);
$sql = "select * from aaa where name = 'test1'";
$re = mysql_query($sql,$conn);
$list = mysql_fetch_array($re);
$text = implode ("<br />",$list);
echo $text;
?>

 

i have 10 fileds in mysql which name = test1 .

when i type "select * from aaa where name=test 1" in mysql command, it shows me all the 10 resault

but when i do the above code,  it shows me only the first row in that table, and it echo each value of the field 2 times !

like

1

1

asd

asd

john

john

 

 

 

what is wrong about that  ? how can i get all the rows ?

Link to comment
https://forums.phpfreaks.com/topic/79673-same-line-diffrent-in-sql-and-php/
Share on other sites

Each call to a mysql_fetch_xxxxx() function only fetches one row from a result set, like the php manual states. To fetch all rows from a result set, you would need to use something like a while() loop to iterate over the result set, like the mysql examples in the php manual.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.