Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mySql get results by row number 1

Status
Not open for further replies.

RobBroekhuis

Technical User
Joined
Oct 15, 2001
Messages
1,971
Location
US
Another newbie question: I'm executing a query, and want to display the results in a tabular format as follows:

<result1> <result6> <result11>
<result2> <result7>
<result3> <result8>
<result4> <result9>
<result5> <result10>

I can access mySql_num_rows on the query result and figure out how to go through a loop to create the tabular results. But I haven't figured out how to return result rows by sequential number, rather than just one at a time using mysql_fetch_array(). Is there an easy way to accomplish this, or do I need to read my results into an array variable first, before creating the table?


Rob
[flowerface]
 
you have the number of records, let's say 18. you want 5 values under each other
what if you just loop through the values

you get the number of records from the recordset with
$list = mysql_num_rows($rs);

so you create a table with 18/5=4 (don't know the upper round function out of my head) cells. when you loop through the values you give a <BR> unless it's dividable by 5 then you give a </td><td>

perhaps this is an idea ?
 
Ah, the simplicity! Yes, of course. By the way, the function to do the round up is ceil().


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top