dealtek@xxxxxxxxx wrote on 12/01/2010 22:52:
I did a query... then I display records like:
<table>
<?php do { ?>
<tr>
<td><?php echo $row_cur['tid']; ?></td>
<td> </td>
</tr>
<?php } while ($row_cur = mysql_fetch_assoc($cur)); ?>
</table>
Q: but how I i just display a particular record with out the do / while
loop?
Just use extract($row_cur); before the table starts. That would give you
first row only
Another approach could be to add " LIMIT 1" to the end of your SQL statement
like just the 2nd record only:
i tried
<?php echo $row_cur['tid',2]; ?>
but this makes an error....
or $row_cur('tid',2) --- hmmm what's the syntax?
Getting only second row, but not the first? That would be using a count
var and show only data if count == 2
<table>
<?php
$count=0;
do {
$count++;
if($count == 2) {
echo '
<tr>
<td>'. $row_cur['tid'] .'</td>
<td> </td>
</tr>';
}
} while ($row_cur = mysql_fetch_assoc($cur));
?>
</table>
Another thing: drop the do and use this syntax instead, it's more readable:
<table>
<?php
$count=0;
while ($row_cur = mysql_fetch_assoc($cur)) {
$count++;
if($count == 2) {
echo '
<tr>
<td>'. $row_cur['tid'] .'</td>
<td> </td>
</tr>';
}
}
?>
</table>
--
Kind regards
Kim Emax - masterminds.dk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php