luke1983 Posted May 28, 2009 Share Posted May 28, 2009 Hi i am new to PHP and MySQL, i have read the basic pagination and then tested and it worked great, i then tried to make it into tables i used the code below but i cannot get it to work, it shows the tables but nothing is in them. i am still using the full pagination code and number and id until i understand it better. thanks for your help inadvance. // get the info from the db $sql = "SELECT id, number FROM numbers ORDER BY id DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); // while there are rows to be fetched... ?> <table border="1" cellspacing="1" cellpadding="1" style="width: 628px"> <tr> <th class="style1">ID</th> <th class="style1">Number</th> </tr> <? echo "<table>"; while ($list = mysql_fetch_assoc($result)) { ?> "<tr>"; "<td><font color='red'><? $list['id'] ?></font></td> "<td><font color='red'><? $list['number'] ?></font></td> "</tr>"; <? } // end while echo "</table>"; ?> Thanks Guys Quote Link to comment https://forums.phpfreaks.com/topic/160011-solved-pagination-with-tables-help/ Share on other sites More sharing options...
luke1983 Posted May 28, 2009 Author Share Posted May 28, 2009 Sry i also forgot to ask how to make the number section link to another page. i have being using the following code on other projects but i dont think this would work <td><a href="View.php?id=<? echo "$id"; ?>">Veiw</a></td> Quote Link to comment https://forums.phpfreaks.com/topic/160011-solved-pagination-with-tables-help/#findComment-844069 Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 <? $list['id'] ?> should be <?php echo $list['id']; ?> same idea with $list['number'] Quote Link to comment https://forums.phpfreaks.com/topic/160011-solved-pagination-with-tables-help/#findComment-844071 Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 Sry i also forgot to ask how to make the number section link to another page. i have being using the following code on other projects but i dont think this would work <td><a href="View.php?id=<? echo "$id"; ?>">Veiw</a></td> the link will be fine, but if the other pages exists or knows how to use the get i can't say without seeing it! Quote Link to comment https://forums.phpfreaks.com/topic/160011-solved-pagination-with-tables-help/#findComment-844074 Share on other sites More sharing options...
Goafer Posted May 28, 2009 Share Posted May 28, 2009 umm, the php has been closed mid-loop, is that really allowed? Quote Link to comment https://forums.phpfreaks.com/topic/160011-solved-pagination-with-tables-help/#findComment-844078 Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 umm, the php has been closed mid-loop, is that really allowed? Yep, works with anything, heres an IF statement example <?php if(true){ ?> this is true <?php }else{ ?> This won't be seen <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/160011-solved-pagination-with-tables-help/#findComment-844079 Share on other sites More sharing options...
luke1983 Posted May 28, 2009 Author Share Posted May 28, 2009 Works great thanks guys. its always something simple that you miss and you pull your hair out for hours lol Quote Link to comment https://forums.phpfreaks.com/topic/160011-solved-pagination-with-tables-help/#findComment-844103 Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 Yeah sometimes a second set of eyes helps, if this is solved please click topic solved (bottom left) Quote Link to comment https://forums.phpfreaks.com/topic/160011-solved-pagination-with-tables-help/#findComment-844106 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.