PDA

View Full Version : how to show all records from database???


tanhaha_how
12-06-2006, 09:58 AM
hello, how to show all records from database....(i mean row by row).for my code, i jz can only show the last record....y???


$query = "SELECT * FROM tblpatient";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
while ($row = mysql_fetch_assoc($result)){
echo $row['Name'];
echo '<br/>';
echo $row['Address'];
}


can anyone pls help me???thank u very much:o

bhakti_thakkar
12-06-2006, 10:23 AM
hi,

$query = "SELECT * FROM tblpatient";
$result = mysql_query($query);
//$row = mysql_fetch_assoc($result);
while ($row = mysql_fetch_assoc($result)){
echo $row['Name'];
echo '<br/>';
echo $row['Address'];
}

just comment the line in bold and see.its should work

tanhaha_how
12-06-2006, 10:47 AM
hi,

$query = "SELECT * FROM tblpatient";
$result = mysql_query($query);
//$row = mysql_fetch_assoc($result);
while ($row = mysql_fetch_assoc($result)){
echo $row['Name'];
echo '<br/>';
echo $row['Address'];
}

just comment the line in bold and see.its should work

ooo,thank u very much...it works oledi....:thumbsup: