searls03 Posted December 12, 2011 Share Posted December 12, 2011 ok, I can't seem to figure out how to go about this. I have a form where pics can be uploaded with certain id's which will tell them where they are placed, in apDiv2-9. the main id is how this is going to be identified. I would like it also so that once there are 8 products, a new page will begin, starting with apDiv10-18(I need the 2-9 to automatically change to 10-18, so like it would be if results are greatehr than 8, then apdiv will add 8 to the number part of it). I would like it to pull the image link from the database in the tag $image which will have to be pulled according to the apDiv#. how would I do this? does this make sense? this is extremely hard to explain. this is not the code that posts, this is the code that displays here is code: <?php include_once "connect_to_mysql_1.php"; $sql = mysql_query("SELECT * FROM products"); while($row = mysql_fetch_array($sql)){ $image = $row['link']; } ?> <!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=UTF-8" /> <meta name="description" content="Thank you for your interest in Old Mil-custom Woodworking. We have hired Aaron's Web Design to build a brand new website for us! Thank you for your patience!"> <meta name="keywords" content="Web, Design, web design, old, mil, oldmil, old mil, wood, woodwork, work, working, woodworking, woodworker, woodworkers, custom"> <title>Our Products-Old Mil</title> <style type="text/css"> <!-- body { font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif; background: #42413C; margin: 0; padding: 0; color: #000; background-image: url(../images/background.png); } /* ~~ Element/tag selectors ~~ */ ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */ padding: 0; margin: 0; } h1, h2, h3, h4, h5, h6, p { margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */ padding-right: 15px; padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */ font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 100%; } a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */ border: none; } /* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */ a:link { color: #42413C; text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */ } a:visited { color: #6E6C64; text-decoration: underline; } a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */ text-decoration: none; } /* ~~this fixed width container surrounds the other divs~~ */ .container { width: 960px; background: #FFF; margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */ } /* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */ .header { background: #ADB96E; font-size: xx-large; font-family: "Comic Sans MS", cursive; height:137px; } /* ~~ These are the columns for the layout. ~~ 1) Padding is only placed on the top and/or bottom of the divs. The elements within these divs have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design. 2) No margin has been given to the columns since they are all floated. If you must add margin, avoid placing it on the side you're floating toward (for example: a right margin on a div set to float right). Many times, padding can be used instead. For divs where this rule must be broken, you should add a "display:inline" declaration to the div's rule to tame a bug where some versions of Internet Explorer double the margin. 3) Since classes can be used multiple times in a document (and an element can also have multiple classes applied), the columns have been assigned class names instead of IDs. For example, two sidebar divs could be stacked if necessary. These can very easily be changed to IDs if that's your preference, as long as you'll only be using them once per document. 4) If you prefer your nav on the right instead of the left, simply float these columns the opposite direction (all right instead of all left) and they'll render in reverse order. There's no need to move the divs around in the HTML source. */ .sidebar1 { float: left; width: 180px; background: #EADCAE; padding-bottom: 10px; height:770px } .content { padding: 10px 0; width: 780px; float: left; } /* ~~ This grouped selector gives the lists in the .content area space ~~ */ .content ul, .content ol { padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above. Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention. These may be adjusted as you wish. */ } /* ~~ The navigation list styles (can be removed if you choose to use a premade flyout menu like Spry) ~~ */ ul.nav { list-style: none; /* this removes the list marker */ border-top: 4px solid #666; /* this creates the top border for the links - all others are placed using a bottom border on the LI */ margin-bottom: 4px solid #666; /* this creates the space between the navigation on the content below */ } ul.nav li { border-bottom: 4px solid #666; /* this creates the button separation */ } ul.nav a, ul.nav a:visited { /* grouping these selectors makes sure that your links retain their button look even after being visited */ padding: 5px 5px 5px 15px; display: block; /* this gives the link block properties causing it to fill the whole LI containing it. This causes the entire area to react to a mouse click. */ width: 160px; /*this width makes the entire button clickable for IE6. If you don't need to support IE6, it can be removed. Calculate the proper width by subtracting the padding on this link from the width of your sidebar container. */ text-decoration: none; background-image: url(/images/slat.png); } ul.nav a:hover, ul.nav a:active, ul.nav a:focus { /* this changes the background and text color for both mouse and keyboard navigators */ background-image: url(/images/slat1.png); color: #000; } /* ~~ The footer ~~ */ .footer { padding: 10px 0; background: #CCC49F; position: relative;/* this gives IE6 hasLayout to properly clear */ clear: both; /* this clear property forces the .container to understand where the columns end and contain them */ } /* ~~ miscellaneous float/clear classes ~~ */ .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */ float: right; margin-left: 8px; } .fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */ float: left; margin-right: 8px; } .clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */ clear:both; height:0; font-size: 1px; line-height: 0px; } .container .sidebar1 .nav li a div { color: #000; padding: 0px; } #apDiv1 { position:relative; left:160px; top:-130px; width:772px; height:88px; z-index:1; } #ap12 { position:relative; top:-50px; left:00px; width:772px; height:88px; z-index:1; } #apDiv2 { position:relative; left:30px; top:30px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv3 { position:relative; left:450px; top:-240px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv4 { position:relative; left:30px; top:-190px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv5 { position:relative; left:450px; top:-460px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv6 { position:relative; left:30px; top:-410px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv7 { position:relative; left:450px; top:-680px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv8 { position:relative; left:30px; top:-630px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv9 { position:relative; left:450px; top:-900px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } --> </style></head> <body> <div class="container"> <div class="header"><a href="#"><img src="../images/Old Mil LOGO.jpg" alt="Insert Logo Here" name="Insert_logo" width="122" height="137" id="Insert_logo" style="background: #C6D580; display:block;" /> <div id="apDiv1"><span class="header">Old Mil<br /> Custom Woodworking, Inc. </span></div></a><!-- end .header --></div> <div class="sidebar1"> <ul class="nav"> <li><a href="/Products"> <div font color="black">Products</div></a></li> <li><a href="#"> <div font color="black">Coming Soon</div></a></li> <li><a href="#"> <div font color="black">Coming Soon</div></a></li> <li><a href="#"> <div font color="black">Coming Soon</div></a></li> </ul> <p> </p> <!-- end .sidebar1 --></div> <div class="content"> <h1> </h1> <h1><br /> <div id="apDiv2"> <img src="<?php echo $image; ?>" width="700" height="300" /> </div><div id="apDiv3"> <img src="<?php echo $image; ?>" width="700" height="300" /> </div> <div id="apDiv4"> <img src="<?php echo $image; ?>" width="700" height="300" /> </div> <div id="apDiv5"> <img src="<?php echo $image; ?>" width="700" height="300" /> </div> <div id="apDiv6"> <img src="<?php echo $image; ?>" width="700" height="300" /> </div><div id="apDiv7"> <img src="<?php echo $image; ?>" width="700" height="300" /> </div> <div id="apDiv8"> <img src="<?php echo $image; ?>" width="700" height="300" /> </div> <div id="apDiv9"> <img src="<?php echo $image; ?>" width="700" height="300" /> </div><br /><br /><br /><br /> </h1> <!-- end .content --></div> <p> </p> <p> </p> <div class="footer"> <p>Website made by <a href="http://www.aaronswebdesign.infiniteserve.com">Aaron's Web Design</a></p> <!-- end .footer --></div> <!-- end .container --></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/ Share on other sites More sharing options...
searls03 Posted December 12, 2011 Author Share Posted December 12, 2011 so I have something that works for the first page, but I need to know how to make a second page generate automatically and how to make it so that the all the numbers still add 8 to for every page. or is there a better way to do it? <?php include_once "connect_to_mysql_1.php"; ?> <!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=UTF-8" /> <meta name="description" content="Thank you for your interest in Old Mil-custom Woodworking. We have hired Aaron's Web Design to build a brand new website for us! Thank you for your patience!"> <meta name="keywords" content="Web, Design, web design, old, mil, oldmil, old mil, wood, woodwork, work, working, woodworking, woodworker, woodworkers, custom"> <title>Our Products-Old Mil</title> <style type="text/css"> <!-- body { font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif; background: #42413C; margin: 0; padding: 0; color: #000; background-image: url(../images/background.png); } /* ~~ Element/tag selectors ~~ */ ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */ padding: 0; margin: 0; } h1, h2, h3, h4, h5, h6, p { margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */ padding-right: 15px; padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */ font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 100%; } a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */ border: none; } /* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */ a:link { color: #42413C; text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */ } a:visited { color: #6E6C64; text-decoration: underline; } a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */ text-decoration: none; } /* ~~this fixed width container surrounds the other divs~~ */ .container { width: 960px; background: #FFF; margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */ } /* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */ .header { background: #ADB96E; font-size: xx-large; font-family: "Comic Sans MS", cursive; height:137px; } /* ~~ These are the columns for the layout. ~~ 1) Padding is only placed on the top and/or bottom of the divs. The elements within these divs have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design. 2) No margin has been given to the columns since they are all floated. If you must add margin, avoid placing it on the side you're floating toward (for example: a right margin on a div set to float right). Many times, padding can be used instead. For divs where this rule must be broken, you should add a "display:inline" declaration to the div's rule to tame a bug where some versions of Internet Explorer double the margin. 3) Since classes can be used multiple times in a document (and an element can also have multiple classes applied), the columns have been assigned class names instead of IDs. For example, two sidebar divs could be stacked if necessary. These can very easily be changed to IDs if that's your preference, as long as you'll only be using them once per document. 4) If you prefer your nav on the right instead of the left, simply float these columns the opposite direction (all right instead of all left) and they'll render in reverse order. There's no need to move the divs around in the HTML source. */ .sidebar1 { float: left; width: 180px; background: #EADCAE; padding-bottom: 10px; height:770px } .content { padding: 10px 0; width: 780px; float: left; } /* ~~ This grouped selector gives the lists in the .content area space ~~ */ .content ul, .content ol { padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above. Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention. These may be adjusted as you wish. */ } /* ~~ The navigation list styles (can be removed if you choose to use a premade flyout menu like Spry) ~~ */ ul.nav { list-style: none; /* this removes the list marker */ border-top: 4px solid #666; /* this creates the top border for the links - all others are placed using a bottom border on the LI */ margin-bottom: 4px solid #666; /* this creates the space between the navigation on the content below */ } ul.nav li { border-bottom: 4px solid #666; /* this creates the button separation */ } ul.nav a, ul.nav a:visited { /* grouping these selectors makes sure that your links retain their button look even after being visited */ padding: 5px 5px 5px 15px; display: block; /* this gives the link block properties causing it to fill the whole LI containing it. This causes the entire area to react to a mouse click. */ width: 160px; /*this width makes the entire button clickable for IE6. If you don't need to support IE6, it can be removed. Calculate the proper width by subtracting the padding on this link from the width of your sidebar container. */ text-decoration: none; background-image: url(/images/slat.png); } ul.nav a:hover, ul.nav a:active, ul.nav a:focus { /* this changes the background and text color for both mouse and keyboard navigators */ background-image: url(/images/slat1.png); color: #000; } /* ~~ The footer ~~ */ .footer { padding: 10px 0; background: #CCC49F; position: relative;/* this gives IE6 hasLayout to properly clear */ clear: both; /* this clear property forces the .container to understand where the columns end and contain them */ } /* ~~ miscellaneous float/clear classes ~~ */ .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */ float: right; margin-left: 8px; } .fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */ float: left; margin-right: 8px; } .clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */ clear:both; height:0; font-size: 1px; line-height: 0px; } .container .sidebar1 .nav li a div { color: #000; padding: 0px; } #apDiv1 { position:relative; left:160px; top:-130px; width:772px; height:88px; z-index:1; } #ap12 { position:relative; top:-50px; left:00px; width:772px; height:88px; z-index:1; } #apDiv2 { position:relative; left:30px; top:30px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv3 { position:relative; left:450px; top:-240px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv4 { position:relative; left:30px; top:-190px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv5 { position:relative; left:450px; top:-460px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv6 { position:relative; left:30px; top:-410px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv7 { position:relative; left:450px; top:-680px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv8 { position:relative; left:30px; top:-630px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } #apDiv9 { position:relative; left:450px; top:-900px; width:270px; height:270px; z-index:2; background-color: #CCCCCC; } --> </style></head> <body> <div class="container"> <div class="header"><a href="#"><img src="../images/Old Mil LOGO.jpg" alt="Insert Logo Here" name="Insert_logo" width="122" height="137" id="Insert_logo" style="background: #C6D580; display:block;" /> <div id="apDiv1"><span class="header">Old Mil<br /> Custom Woodworking, Inc. </span></div></a><!-- end .header --></div> <div class="sidebar1"> <ul class="nav"> <li><a href="/Products"> <div font color="black">Products</div></a></li> <li><a href="#"> <div font color="black">Coming Soon</div></a></li> <li><a href="#"> <div font color="black">Coming Soon</div></a></li> <li><a href="#"> <div font color="black">Coming Soon</div></a></li> </ul> <p> </p> <!-- end .sidebar1 --></div> <div class="content"> <h1> </h1> <h1><br /> <div id="apDiv2"> <?php $sql = mysql_query("SELECT * FROM products where id='2'"); while($row = mysql_fetch_array($sql)){ $image2 = $row['link']; } ; ?><img src="<?php echo $image2;?> " width="300" /> </div><div id="apDiv3"> <?php $sql = mysql_query("SELECT * FROM products where id='3'"); while($row = mysql_fetch_array($sql)){ $image3 = $row['link']; } ; ?><img src="<?php echo $image3;?> " width="300" /> </div> <div id="apDiv4"> <?php $sql = mysql_query("SELECT * FROM products where id='4'"); while($row = mysql_fetch_array($sql)){ $image4 = $row['link']; } ; ?><img src="<?php echo $image4;?> " width="300" /> </div> <div id="apDiv5"> <?php $sql = mysql_query("SELECT * FROM products where id='5'"); while($row = mysql_fetch_array($sql)){ $image5 = $row['link']; } ; ?><img src="<?php echo $image5;?> " width="300" /> </div> <div id="apDiv6"> <?php $sql = mysql_query("SELECT * FROM products where id='6'"); while($row = mysql_fetch_array($sql)){ $image6 = $row['link']; } ; ?><img src="<?php echo $image6;?> " width="300" /> </div><div id="apDiv7"> <?php $sql = mysql_query("SELECT * FROM products where id='7'"); while($row = mysql_fetch_array($sql)){ $image7 = $row['link']; } ; ?><img src="<?php echo $image7;?> " width="300" /> </div> <div id="apDiv8"> <?php $sql = mysql_query("SELECT * FROM products where id='8'"); while($row = mysql_fetch_array($sql)){ $image8 = $row['link']; } ; ?><img src="<?php echo $image8;?> " width="300" /> </div> <div id="apDiv9"> <?php $sql = mysql_query("SELECT * FROM products where id='9'"); while($row = mysql_fetch_array($sql)){ $image9 = $row['link']; } ; ?><img src="<?php echo $image9;?> " width="300" /> </div><br /><br /><br /><br /> </h1> <!-- end .content --></div> <p> </p> <p> </p> <div class="footer"> <p>Website made by <a href="http://www.aaronswebdesign.infiniteserve.com">Aaron's Web Design</a></p> <!-- end .footer --></div> <!-- end .container --></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/#findComment-1296990 Share on other sites More sharing options...
Drummin Posted December 12, 2011 Share Posted December 12, 2011 Rather than hard coding each division I would have the display within the looping query so that for each image, the id is applied to the div and image is shown. At the top of the page I would define the base number of the images to be shown on the page and in the query add "limit 8" to only show eight images. A simple "Next" link could be added to show the next set. So you'd have something like this at the top. <?php if (isset($_GET['basenumber']) && is_numeric($_GET['basenumber'])){ $basenumber=$_GET['basenumber']; } else{ $basenumber=2; } ?> And then for the display section, something like this. <?php $sql = mysql_query("SELECT id, link FROM products WHERE id>='$basenumber' limit 8"); while($row = mysql_fetch_array($sql)){ $imageid = $row['id']; $image2 = $row['link']; ?> <div id="apDiv<?php echo $imageid;?>"><img src="<?php echo $image2;?> " width="300" /></div> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/#findComment-1297020 Share on other sites More sharing options...
searls03 Posted December 12, 2011 Author Share Posted December 12, 2011 How would i do this so that the css would do the same basic thing, update the number? Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/#findComment-1297073 Share on other sites More sharing options...
Drummin Posted December 12, 2011 Share Posted December 12, 2011 I would learn about floats. One common div would float left inside a wrapper div. Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/#findComment-1297117 Share on other sites More sharing options...
searls03 Posted December 12, 2011 Author Share Posted December 12, 2011 I know about float a bit, but how would I can't seem to wrap my head around how I would make it line up the exact way I would want to. Could you assist me a bit? Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/#findComment-1297267 Share on other sites More sharing options...
Drummin Posted December 12, 2011 Share Posted December 12, 2011 See if this helps. if (isset($_GET['basenumber']) && is_numeric($_GET['basenumber'])){ $basenumber=$_GET['basenumber']; } else{ $basenumber=2; } ?> <?xml version="1.0" encoding="windows-1252"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <title></title> <style type="text/css"> .imageholder{ float:left; padding:0; margin:10px; width:300px; } .imagewrapper{ float:left; padding:0; margin:0; width:960px; } </style> </head> <body> <div class="imagewrapper"> <?php $sql = mysql_query("SELECT id, link FROM products WHERE id>='$basenumber' limit 8"); while($row = mysql_fetch_array($sql)){ $imageid = $row['id']; $image2 = $row['link']; ?> <div class="imageholder"><div id="apDiv<?php echo $imageid;?>"><img src="<?php echo $image2;?> " width="300" /></div></div> <?php } ?> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/#findComment-1297276 Share on other sites More sharing options...
searls03 Posted December 12, 2011 Author Share Posted December 12, 2011 YES!!!!! thank you. one more question, what is the base number? how does it work? I know that is how I would use it for more pictures, but would it be like .......php?basenumber=1? in the url. would it be 1, 2, 3, etc. or does it be like 2, 8, or whatever since it says if not set it equals 2? Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/#findComment-1297281 Share on other sites More sharing options...
Drummin Posted December 13, 2011 Share Posted December 13, 2011 I need the 2-9 to automatically change to 10-18The sample I provided was based on this quote in that you wanted to start with id 2 and show 8 images and then start with id 10 and show the next 8 images. The variable named $basenumber represents that starting id we are using and then as we've done, we show 8 images, i.e. images 2-9 or 10-18. The $basenumber tells us where we're starting from, i.e. 2 or 10 etc. I believe what you're wanting is to have links like "NEXT" for showing the next set of eight images. The very basics is that you're making the link "?basenumber=something" eight numbers higher than the last. I threw this together off the top of my head and it's not tested. Look into pagination for details on how to do more accurate paging links. <?PHP if (isset($_GET['basenumber']) && is_numeric($_GET['basenumber'])){ $basenumber=$_GET['basenumber']; } else{ $basenumber=2; } ?> <?xml version="1.0" encoding="windows-1252"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <!-- Created on: 12/12/2011 --> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <title></title> <style type="text/css"> .imageholder{ float:left; padding:0; margin:10; width:300px; } .imagewrapper{ float:left; padding:0; margin:0; width:960px; } .paging{ float:left; padding:0; margin:0; width:960px; text-align:center; } </style> </head> <body> <div class="imagewrapper"> <?php $sql = mysql_query("SELECT id, link FROM products WHERE id>='$basenumber' limit 8"); while($row = mysql_fetch_array($sql)){ $imageid = $row['id']; $image2 = $row['link']; ?> <div class="imageholder"><div id="apDiv<?php echo $imageid;?>"><img src="<?php echo $image2;?> " width="300" /></div></div> <?php } ?> </div> <?php //Adding this after the closing bracket of the array should assign the last image id to the variable $imageid. if(isset($basenumber) && $basenumber>2){ //Get last product id $getlastproductid = mysql_query("SELECT id FROM products ORDER BY id DESC limit 1"); while($lproductid = mysql_fetch_array($getlastproductid)){ $lastid=$lproductid['id']; } echo "<div class=\"paging\">"; $backbasenumber=$basenumber-8; if($basenumber>8 && $backbasenumber>2){ $backbasenumber=$basenumber-8; } else{ $backbasenumber=2; } echo "<a href=\"mysite.com/thispage.php?basenumber=$backbasenumber\">Back</a> "; } $nextbasenumber=$imageid+8; if($nextbasenumber<$lastid){ echo "<a href=\"mysite.com/thispage.php?basenumber=$nextbasenumber\">Next</a>"; } echo "</div>"; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/#findComment-1297337 Share on other sites More sharing options...
searls03 Posted December 13, 2011 Author Share Posted December 13, 2011 it is doing 3 images across. how do i make it so that it is only 2 acros Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/#findComment-1297643 Share on other sites More sharing options...
Drummin Posted December 13, 2011 Share Posted December 13, 2011 Change the css widths so only two with padding fit in the container div. Quote Link to comment https://forums.phpfreaks.com/topic/252972-products-page/#findComment-1297644 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.