e1seix Posted July 22, 2007 Share Posted July 22, 2007 inquired on another forum about showing search results from mysql in rows, for example: the first 4 results on one row, the next four on the one after etc. etc. to a maximum of 16 before the user has to move on to the "next page to display any remaining results. i was given this code: <table> <?php $rowwidth = 4; for($i = @$_GET['start'] or 0; $row = mysql_fetch_array($rs) && $i < @$_GET['num'] or 16; ++$i) { if($i % $rowwidth === 0) { if($i !== @$_GET['start'] or 0) { ?> </tr> <?php } ?> <tr> <?php } ?> <td><?php echo $row['result']; ?></td> <?php } ?> </tr> </table> i need to morph this code into my template already. can anyone help? lol <td> $ID = $_GET['ID']; $result = mysql_query("SELECT * FROM fragrances WHERE ID=$ID ORDER BY PRO") or die(mysql_error()); echo "<table border='0' cellpadding='5' cellspacing='0' width='500'>"; while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td align='center' bgcolor='#ffffff' width='125'><p class='brand_div'>"; echo $row['ima_link']; echo "</p></td></tr><tr><td align='center' bgcolor='#ffffff' width='125'><p class='brand_head'>"; echo $row['PRO']; echo "</p></td></tr><tr><td align='center' bgcolor='#ffffff' width='125'><p class='brand_cli'>"; echo $row['cli_link']; echo "</p></td></tr><tr><td align='center' bgcolor='#ffffff' width='500'><hr color='#cccccc' width='125'></td></tr>"; } echo "</table>"; ?> </td> thank you in advance!! Quote Link to comment Share on other sites More sharing options...
e1seix Posted July 22, 2007 Author Share Posted July 22, 2007 apologies for saying this was an emergency. have just read rule in guidelines. i was just stating it's an emergency that i get this solved for my own needs. lol. i'd be grateful of any guidance Quote Link to comment Share on other sites More sharing options...
e1seix Posted July 22, 2007 Author Share Posted July 22, 2007 i don't suppose anyone maybe has an easier way of doing this, not necessarily applying the first bit of code to the second but getting the same result ultimately. i keep getting error messages no matter what i try Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 22, 2007 Share Posted July 22, 2007 There's a post here on the first part of your problem: http://www.phpfreaks.com/forums/index.php/topic,95426.0.html That is to help you get your results in 4 columns. The second part of your question, where you say you want to have multiple pages, is called pagination. There are two tutorials on this site for pagination: http://www.phpfreaks.com/tutorial_cat/25/Page-Number--Pagination.php I think thats what you need. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.