Okay, stop and take a break. Now come back to the problem and ask
yourself how you can display the results, two at a time on each row.
After you display every second item, you want to end the row and start
another one. Something like this...
<?
$result = mysql_query(" ... get all rows ... ");
echo "<table><tr>";
while($r = mysql_fetch_row($result))
{
echo "<td>show your data here, $r[0], $r[1], etc...</td>";
if($i++ & 1) { echo "</tr>\n<tr>"; }
}
echo "</table>";
?>
but you'll have to come up with a way to handle an odd number of rows
being returned and making it format the table properly, etc...
Hope that helps.
---John Holmes...
> -----Original Message-----
> From: Darren McPhee [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, November 17, 2002 9:17 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Query to select every other record
>
> Does anybody know of a SELECT QUERY that will select every other
record of
> a
> table ? I want to do this so that I can display my products in 2
columns
> (I
> will also be using arrays of course).
>
> The first column would show the result of the first query starting at
> record
> 1. The second column would show the result of the second query
starting
> at
> record 2. Each query just needs to skip a record so that products are
> ordered correctly (1,2 in first row. 3,4 in second row...)
>
> And I want the query to work without relying on ID fields. The reason
> being
> is that when you delete a record, you can end up with a column ID of
say
> 1,2,3,5 (like if you delete record 4).
>
> Originally, I set up my tables up using Dreamweaver with repeat
regions.
> But that's only ok if you want one record per row going down
vertically.
> The Macromedia web site does show you how to display all your records
> repeating horizontally but doesn't tell you how to limit to 2 columns.
So
> both ways are useless to me.
>
> Darren.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php