sniperscope Posted December 13, 2008 Share Posted December 13, 2008 hi all ! I have a serious problem which i can not solve by my self. My problem is, i want to display db records as 1st record 2nd record 3rd record4th record And so far i can get only 1st Record 2nd Record 3rd Record 4th Record I will be really appreciate if any one try to solve small(for you) but big(for me) problem. Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/ Share on other sites More sharing options...
champoi Posted December 13, 2008 Share Posted December 13, 2008 can you post your code? try using a loop and a table. Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714493 Share on other sites More sharing options...
sniperscope Posted December 13, 2008 Author Share Posted December 13, 2008 Here is a sample script. When you execute this script it makes 1st Record1st Record 1st Record1st Record 2nd Record2nd Record 2nd Record2nd Record <?php $host_name = "localhost"; $db = "my_db"; $u_name = "root"; $pass = "root_pass"; $is = mysql_pconnect($host_name, $u_name, $pass) or trigger_error(mysql_error(),E_USER_ERROR); ?> <?php mysql_select_db($db, $is); $query_Rs = "SELECT name, dimension FROM stone ORDER BY name DESC"; $Rset = mysql_query($query_Rs, $is) or die(mysql_error()); $row_Rs = mysql_fetch_assoc($Rset); $totalRows = mysql_num_rows($Rset); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=shift_jis" /> <title>Untitled Document</title> </head> <body> <?php do { ?> <table width="100%" border="1"> <tr> <td><table width="100%" border="1"> <tr> <td><?php echo $row_Rs['name']; ?></td> <td><?php echo $row_Rs['dimension']; ?></td> </tr> </table></td> <td><table width="100%" border="1"> <tr> <td><?php echo $row_Rs['name']; ?></td> <td><?php echo $row_Rs['dimension']; ?></td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="1"> <tr> <td><?php echo $row_Rs['name']; ?></td> <td><?php echo $row_Rs['dimension']; ?></td> </tr> </table></td> <td><table width="100%" border="1"> <tr> <td><?php echo $row_Rs['name']; ?></td> <td><?php echo $row_Rs['dimension']; ?></td> </tr> </table></td> </tr> </table> <?php } while ($row_Rs = mysql_fetch_assoc($Rset)); ?> </body> </html> <?php mysql_free_result($Rset); ?> Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714499 Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 It is because you are outputting each db row in a different table row. Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714509 Share on other sites More sharing options...
sniperscope Posted December 13, 2008 Author Share Posted December 13, 2008 It is because you are outputting each db row in a different table row. Any solution ? I will really regard if you tell me the solution. Because my query return veeeeeeeeery long page. And i want to show 8 records in one page in one table and then paging like NEXT > NEXT....etc Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714517 Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 Try this: Not sure how it will work but try it out and then tell us what happened. <?php $host_name = "localhost"; $db = "my_db"; $u_name = "root"; $pass = "root_pass"; $is = mysql_pconnect($host_name, $u_name, $pass) or trigger_error(mysql_error(),E_USER_ERROR); ?> <?php mysql_select_db($db, $is); $query_Rs = "SELECT name, dimension FROM stone ORDER BY name DESC"; $Rset = mysql_query($query_Rs, $is) or die(mysql_error()); $row_Rs = mysql_fetch_assoc($Rset); $totalRows = mysql_num_rows($Rset); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=shift_jis" /> <title>Untitled Document</title> </head> <body> <div style="width:100%; clear:both; padding:5px;"> <?php do { ?> <div style="width:250px; margin:5px; border:1px #CCCCCC solid; padding:5px; float:left;"> <?php echo $row_Rs['name']; ?><br /> <?php echo $row_Rs['dimension']; ?> </div> <?php } while ($row_Rs = mysql_fetch_assoc($Rset)); ?> </div> </body> </html> <?php mysql_free_result($Rset); ?> Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714524 Share on other sites More sharing options...
sniperscope Posted December 13, 2008 Author Share Posted December 13, 2008 Try this: Not sure how it will work but try it out and then tell us what happened. One word.. Wonderful. And could you PLEASE explain me why and how your code worked but not mine. Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714527 Share on other sites More sharing options...
sniperscope Posted December 13, 2008 Author Share Posted December 13, 2008 And how about if i want to put <table width="200" border="1"> <tr> <td>Product NAME goes here</td> <td rowspan="2">Product Dimension goes here</td> </tr> <tr> <td>Product Picture goes here</td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714530 Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 Well, you were using tables, which I find particularly nasty. I used div tags and styled them with CSS to give them structure. <div style="width:100%; clear:both; padding:5px;"> This is what I wrapped all the rows inside. It's pretty simple. It keeps the width at 100% and adds some padding to make it neater looking. <div style="width:250px; margin:5px; border:1px #CCCCCC solid; padding:5px; float:left;"> Sets the width of each box at 250px, adds a margin to keep the boxes from rubbing up against each other, adds a little border to show you where one starts and another ends, adds some padding and makes each box float to the left. You should probably add a height onto it too, if you want it to look more structured. Try <div style="width:250px; margin:5px; border:1px #CCCCCC solid; padding:5px; float:left; height:250px;"> Mess around with the width and height of the div until you're happy. Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714531 Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 For pictures try: Not perfect, but it should work fine. <?php $host_name = "localhost"; $db = "my_db"; $u_name = "root"; $pass = "root_pass"; $is = mysql_pconnect($host_name, $u_name, $pass) or trigger_error(mysql_error(),E_USER_ERROR); ?> <?php mysql_select_db($db, $is); $query_Rs = "SELECT name, dimension FROM stone ORDER BY name DESC"; $Rset = mysql_query($query_Rs, $is) or die(mysql_error()); $row_Rs = mysql_fetch_assoc($Rset); $totalRows = mysql_num_rows($Rset); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=shift_jis" /> <title>Untitled Document</title> </head> <body> <div style="width:100%; clear:both; padding:5px;"> <?php do { ?> <div style="width:250px; margin:5px; border:1px #CCCCCC solid; padding:5px; float:left;"> <?php echo $row_Rs['name']; ?><br /> <?php echo $row_Rs['dimension']; ?><br /><br /> <div align="center"> Product Picture goes here. </div> </div> <?php } while ($row_Rs = mysql_fetch_assoc($Rset)); ?> </div> </body> </html> <?php mysql_free_result($Rset); ?> Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714532 Share on other sites More sharing options...
sniperscope Posted December 13, 2008 Author Share Posted December 13, 2008 This is how looks in Firefox and how in IE Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714534 Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 Hm. The first box in IE seems to be pushing more in towards the right than the rest. Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714536 Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 Try <?php $host_name = "localhost"; $db = "my_db"; $u_name = "root"; $pass = "root_pass"; $is = mysql_pconnect($host_name, $u_name, $pass) or trigger_error(mysql_error(),E_USER_ERROR); ?> <?php mysql_select_db($db, $is); $query_Rs = "SELECT name, dimension FROM stone ORDER BY name DESC"; $Rset = mysql_query($query_Rs, $is) or die(mysql_error()); $row_Rs = mysql_fetch_assoc($Rset); $totalRows = mysql_num_rows($Rset); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=shift_jis" /> <title>Untitled Document</title> </head> <body> <div style="width:100%; padding:5px;"> <?php do { ?> <div style="width:250px; margin:5px; border:1px #CCCCCC solid; padding:5px; float:left; height:250px;"> <?php echo $row_Rs['name']; ?><br /> <?php echo $row_Rs['dimension']; ?><br /><br /> Product Picture goes here. </div> <?php } while ($row_Rs = mysql_fetch_assoc($Rset)); ?> </div> </body> </html> <?php mysql_free_result($Rset); ?> Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714537 Share on other sites More sharing options...
sniperscope Posted December 13, 2008 Author Share Posted December 13, 2008 Nothings change... Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714540 Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 Your best bet would be to move this topic to the CSS forum as this isn't really a PHP problem anymore. I can bet you that it is something really really simple. I've just overlooked something. If I was working off a PHP enabled computer at the moment, I would test it out. Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714541 Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 http://www.phpfreaks.com/forums/index.php/board,5.0.html Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714542 Share on other sites More sharing options...
sniperscope Posted December 13, 2008 Author Share Posted December 13, 2008 http://www.phpfreaks.com/forums/index.php/board,5.0.html Thank you very much indeed. You can not imagine how you saved me from one of my biggest problem. So i take your advice and make a new topic in CSS. Thank you so much again. Link to comment https://forums.phpfreaks.com/topic/136808-database-paging/#findComment-714548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.