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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.