PDA

View Full Version : display table rows


n3wb!e
06-28-06, 02:06 AM
good morning everyone, i m having this small doubt on tables. how do i display the rows in the table without using the html tags. can i display the fields of the table using only php ?
<?php
.......
............
$sql="select * from questions where qno='$qno'";
$res=mysql_query($sql,$conn);
$rowcount=mysql_num_rows($res);
if($rowcount >=1)
{
while($result = mysql_fetch_row($res))
{
$question=$result[question];
$quesno=$result[qno];
}
echo "$quesno. $question";
}
....
..........
?>

thats not working.. is there any other way that i can print the retrieved row ? thanks in advance.. ciao.

Nico
06-28-06, 05:55 AM
You need HTML to display the table. There's no way around that. You can do something like this



$sql="select * from questions where qno='$qno'";
$res=mysql_query($sql,$conn);
$rowcount=mysql_num_rows($res);
if($rowcount >=1)
{
echo '<table>';

while($result = mysql_fetch_row($res))
{
$question=$result[question];
$quesno=$result[qno];
echo "<tr><td>$quesno. $question</td></tr>";
}
echo '</table>';
}

n3wb!e
06-28-06, 06:32 AM
yup.. thanks bro.. :)