Well, very newbie question here, but I couldn't find the appropiate question to put it on google or here.
I have a very small table, with only 3 rows, every row with a defined id (1, 2, 3).
What I want to do is to print the row data of each one, but avoiding a loop function.
I.e.
The query would be:
$query = "SELECT field1, field2, field3 FROM table";
$var1 = mysql_query($query);
$var2 = mysql_fetch_assoc($var1);
$var3 = mysql_num_rows($var1);
The PHP:
<p><?php echo $var2['field1'];//how can i tell to the code "use the row with this id here -> id=1" ?></p>
<p><?php echo $var2['field1']; // "and use the row with the id "2" here" ?></p>
PS: Sorry about my poor english, argentine dude here.
Ok,
This is why I didn't want to do it as a loop:
I know I can do it this way:
<?php do { ?>
<p>bla bla <?php echo $var2[field1]; ?> </p>
<?php } while ($var2 = mysql_fetch_assoc($var1)); ?>
But it can't be done like this, because the site design puts this data in different divs, with different positioning and CSS formatting.
I would like to do it the right way, avoiding the use o one query per row.
The rows will be forever 3, and the id of each one will always be the same (1, 2, 3).