Jump to content

query to return an array and increment loop


demuro1

Recommended Posts

I have been working on this project all semester and it's almost due. It is a catalog. I need help or suggestions on how to structure this query and a loop to display everything. I previous had this working and I used a for loop to iterate through everything. Now I need to account for a search by the user. So here is what I need help with: I need to structure a query that will return only 3 results per pagefor example on page load-the query returns the entry database-page 1 loads and returns 1,2,3-the user click the next page button-page 2 will load and return items 4,5,6 etc if I run a query and it return results 2,5,7,9,12,14,18,19,27 -page 1 loads and returns items 2,5,7 -the user click the next page button-page 2 will load and return items 9,12,14etc I am kind of desperate for help! I have a query statement at the top of the page to count how many items are returned, this feeds the javascript how many page the catalog will generate I have a query statement in the body of the page that feeds the loop. I assume there is a ways to combine this stuff but I can't get the query to work.

<html><!--Release InformationRelease Version 2.0.0Release Notes:		  -page completely rewritten to take advantage of php--><?php#initialize and declare variables#where do I send the form?$formpath = ($_SERVER['PHP_SELF']);#table attributes$border=1;$edgewidth='15%';$tablealignment='centop';$tealign='cenmid';$visibility='hidden';#error reportingerror_reporting(E_ALL);ini_set('display_errors','1');$link = mysqli_connect('127.0.0.1:3306', 'root', '4pp1353c', 'storedatabase');#check connectionif (mysqli_connect_errno()){printf("Connect failed: %s\n", mysqli_connect_error());exit();}#query string and search$query = "SELECT * FROM inventory ORDER by id ASC";$result = mysqli_query($link, $query);$queryReturn = $result->num_rows;#variables$itemsperpage = 3;$itemsperrow = 3;$rowsperpage = $itemsperpage/$itemsperrow;#page number attributes$maxPage = $queryReturn/$itemsperpage;$previousButton;$nextButton;$pageFieldDefaultValue='Jump to Page';#------------------------------------$pageNumber;if(isset($_POST['pageNumber'])){$pageNumber = $_POST['pageNumber'];}else if(!isset($pageNumber)){$pageNumber=1;}#------------------------------------if($pageNumber==1){$previousButton='=X=X=X= Page '.($pageNumber);}else{$previousButton='<==Go to Page '.($pageNumber-1);}if($pageNumber==$maxPage){$nextButton='=X=X=X= Page '.($pageNumber);}else{$nextButton='Go to Page '.($pageNumber+1).'==>';}#items per pageif(!isset($_POST['itemsperpage'])){$itemsperpage=3;}else{$itemsperpage = $_POST['itemsperpage'];}?><head>  <title>Awesome Shape Store</title>   <style>/*sadly this is done without style*/   .centop    {	 text-align:center;	 vertical-align:top;    }   .cenmid    {	 text-align:center;	 vertical-align:middle;    }   .header    {	 font-family:"courier"	 text-align:center;	 vertical-align:top;	 font-size:250%;	 font-weight:bold;    }   .tiny    {	 font-family:"courier"	 text-align:center;	 vertical-align:top;	 font-size:75%;	 font-style:italic;    }  </style>  <script type='text/javascript'>/*make some magic*//*-========================================-*//*-- Initialization and Display Functions --*//*-========================================-*/   function onLoad()   {    pageNumber()   }    var timer = setTimer("",0); /* reset the timer for add to cart display or other messages */   function alertDisplay(d)   {    var time=2000;     document.getElementById("div_display").innerHTML=d;    clearTimeout(timer);    timer=setTimeout("document.getElementById('div_display').innerHTML=''", time);   }/*End Initialize and Display Functions*//*-===================-*//*-- Set hidden info --*//*-===================-*/   function invisibles()   {      if (document.getElementById('visibles').checked)    {	 document.getElementById('hide1').style.visibility = 'hidden';	 document.getElementById('hide2').style.visibility = 'hidden';    }    else    {	 document.getElementById('hide1').style.visibility = 'visible';	 document.getElementById('hide2').style.visibility = 'visible';    }   }     function itemspp(sel)   {    var items=27; //"<?php echo $queryReturn; ?>";    var itemsperpage = sel.options[sel.selectedIndex].value;    //alert(itemsperpage);       if (items%itemsperpage != 0)    {document.getElementById('nop').innerHTML = (Math.floor(items/itemsperpage)+1);}    else {document.getElementById('nop').innerHTML = (items/itemsperpage);}       form.submit();   }/*-====================-*//*-- Action Functions --*//*-====================-*/   //when you add the php to this button id will be named with a php variable and the variable will be the item id   function addToCart(input,form)   {    alertDisplay('A' + input.id + ' added to cart');    //make an array-store the product id    //if id is added to cart again increment id    //array will store id and quantity   }     function search(input,form)   {    //alert('You Searched for: ' + document.getElementById('searchField').value);    form.submit();   }     /*==-Page Number Function-==*/   function pageNumber(input,form)   {    //alert('You selected ' + input.id);    var maxPage = <?php echo $maxPage; ?>;    var p = parseInt(document.getElementById('pageNumber').value);   //input.id is numberField       if ((input.id == 'pageField') &&    (    (isNaN(document.getElementById('pageField').value)) ||    (parseFloat(document.getElementById('pageField').value) % 1 !== 0) ||    (parseInt(document.getElementById('pageField').value) < 1) ||    (parseInt(document.getElementById('pageField').value) > <?php echo $maxPage; ?>)    ))    {	 alert('I\'m Sorry, ' + document.getElementById('pageField').value + '\ is not a valid page number. \nYou will be returned to page ' + document.getElementById('pageNumber').value);    }    else if (input.id == 'pageField')    {	 document.getElementById('pageNumber').value = parseInt(document.getElementById('pageField').value);    }//input.id is previousPage    else if (input.id == 'previousPage' && p <= 1)    {	 alertDisplay('You are already on page ' + p);	 return;    }    else if (input.id == 'previousPage')    {	 p -= 1;	 document.getElementById('pageNumber').value = p;    }//input.id is nextPage    else if (input.id == 'nextPage' && p >= <?php echo $maxPage; ?>)    {	 alertDisplay('You are on the last page.');	 return;    }    else if (input.id == 'nextPage')    {	 p += 1;	 document.getElementById('pageNumber').value = p;    }    else {alert('pageNumber Error');}    form.submit();   }   /*-===================================-*//*-- Button and Keystroke Submission --*//*-===================================-*/   function buttonSubmit(button,form)   {    if (button.id == 'searchButton')    {	 search(button,form);    }    else if (button.id == 'previousPage' || button.id == 'nextPage')    {	 pageNumber(button,form);    }    else if (button.name == 'addToCart')    {	 //alert(button.name);	 addToCart(button,form);    }    else    {	 alert('button click error');	 alert(button.id);	 alert(form.name);    }   }   function keystrokeSubmit(textbox,e,form)   {    e = e? e : window.event;    var prskeyrtrn = e.keyCode? e.keyCode : e.which? e.which : e.charCode? e.charCode :null;    if (prskeyrtrn == 13 && textbox.id == 'searchField') 	 {	  search(textbox,form);	 }    else if (prskeyrtrn == 13 && textbox.id == 'pageField')	 {	  pageNumber(textbox,form);	 }    else{}    }  </script></head> <body onLoad="onLoad()"><!--=====================--><!--==begin top of page==--><!--=====================--><form name="headForm" id="headForm"  method="POST" action="<?php echo $formpath; ?>">  <table width="100%" class="<?php echo $tablealignment; ?>" border="<?php echo $border; ?>">   <tr class="<?php echo $tealign; ?>"><!--left side of head -->    <td width="<?php echo $edgewidth; ?>">	 <table height="90" border="<?php echo $border; ?>" class="<?php echo $tablealignment; ?>" width="100%">	  <tr class="<?php echo $tealign; ?>"><td><div name="pagediv" id="pagediv">Current Page: <?php echo $pageNumber; ?></div></td></tr>	  <tr class="<?php echo $tealign; ?>"><td><input type="text" id="pageField" name="pageField" placeholder="<?php echo $pageFieldDefaultValue; ?>" onkeypress="keystrokeSubmit(this,event,form)"></td></tr>	  <tr class="<?php echo $tealign; ?>"><td><input style="cursor:pointer" type="button" id="previousPage" name="previousPage" value="<?php echo $previousButton; ?>" onclick="buttonSubmit(this,form);"></td></tr>	 </table>    </td><!--center of head -->    <td class="<?php echo $tealign; ?>" width="80%">		 <table height="90" border="<?php echo $border; ?>" class="<?php echo $tablealignment; ?>" width="100%">							  <tr class="header"><td height="10%">Awesome Shape Store Catalog</td></tr>							  <tr class="<?php echo $tealign; ?>"><td height="90%"><div id="div_display" class="centop"></div></td></tr>						 </table>				    </td><!--right side of head -->    <td width="<?php echo $edgewidth; ?>">	 <table height="90" border="<?php echo $border; ?>" class="<?php echo $tablealignment; ?>" width="100%">	  <tr class="<?php echo $tealign; ?>"><td><input type="text" id="searchField" name="searchField" placeholder="Search" onkeypress="keystrokeSubmit(this,event,form)"></td></tr>	  <tr class="<?php echo $tealign; ?>"><td><input style="cursor:pointer" type="button" id="searchButton" name="searchButton" value="Awesome Search" onclick="buttonSubmit(this,form);"></td></tr>	  <tr class="<?php echo $tealign; ?>"><td><input style="cursor:pointer" type="button" id="nextPage" name="nextPage" value="<?php echo $nextButton; ?>" onclick="buttonSubmit(this,form);"></td></tr>	 </table>    </td>   </tr>  </table><!--This is an invisible table and it holds the pageNumber-->  <table class="tiny" border="<?php echo $border; ?>">   <tr>    <td>	 Page Display Attributes:    </td>    <td colspan="2">	 <input type="checkbox" checked name="visibles" id="visibles" value="show invisibles" onclick="invisibles();">    </td>   </tr>   <tr style="visibility:hidden" name="hideFields" id="hide1">    <td>Current page number</td>    <td>Items per page:</td>    <td>Number of pages:</td>   </tr>   <tr style="visibility:hidden" name="hideFields"id="hide2">    <td><input type="text" id="pageNumber" name="pageNumber" value="<?php echo $pageNumber; ?>"></td>    <td>	 <?php echo $itemsperpage; ?><!--	 <select id="itemsperpage" name="itemsperpage" onchange="itemspp(this);">	  <option value="1">1 item</option>	  <option value="3" selected="selected">3 items</option>	  <option value="6">6 items</option>	  <option value="9">9 items</option>	  <option value="18">18  items</option>	  <option value="27">all items</option>	 </select>-->    </td>    <td><div name="nop" id="nop">9</div></td>   </tr>  </table></form><!--===================--><!--==end top of page==--><!--===================--> <!--=====	 This is a seperator	 ==========	 This is a seperator	 ==========	 This is a seperator	 =====--><!--=====	 This is a seperator	 ==========	 This is a seperator	 ==========	 This is a seperator	 =====--><!--=====	 This is a seperator	 ==========	 This is a seperator	 ==========	 This is a seperator	 =====--> <!--==============================--><!--==begin main section of page==--><!--==============================--><div name="divbody' id="divbody">   <table>    <tr>   <?php    $query = "SELECT * FROM inventory order by id limit ".(($pageNumber-1)*3).",3";    $result = mysqli_query($link, $query);	    while($row = mysql_fetch_assoc($result))    {	 print	 (	  "<td>	  <table>	  <tr>	  <!--catalog image-->	   <td valign='top'><img src='http://localhost/phpTestCode/web%20apps%20labs/Lab%2010/".$row["imageFilename"]."'></td>	   <td><table>	    <tr>	    <!--catalog id-->		 <td valign='top'><b>Item ID:</b></td>		 <td>".$row["id"]."</td>	    </tr>	    <tr>	    <!--catalog name-->		 <td valign='top'><b>Item Name:</b></td>		 <td>".$row["Product_name"]."</td>	    </tr>	    <tr>	    <!--catalog shape-->  		 <td valign='top'><b>Shape:</b></td>		 <td>".$row["shape"]."</td>	    </tr>	    <tr>	    <!--catalog size-->		 <td valign='top'><b>Size:</b></td>		 <td>".$row["size"]."</td>	    </tr>	    <tr>	    <!--catalog color-->		 <td valign='top'><b>Color:</b></td>		 <td><font color=".$row['color'].">".$row["color"]."</td>	    </tr>	    <tr>	    <!--catalog price-->		 <td valign='top'><b>Price:</b></td>		 <td>$".$row["price"]."</td>	    </tr>	    <tr>	    <!--catalog description-->		 <td valign='top'><b>Description:</b></td>		 <td> This is an amazing".$row["size"]." <font color=".$row["color"]."><b>".$row["color"]."</b></font> ".$row["shape"]." with a super cool black border</td>	    </tr>  	   </table></td>	  </tr>	 <!--add to cart button-->	 <!--id set by php-->	 <!--<form name='addToCart' method='POST'action=". $formpath ."'>-->	  <tr><td><input type='button' value='Add to Cart' name='addToCart' id='".$row["Product_name"]."' onclick='buttonSubmit(this,form);'></td></tr>	 <!--</form>-->		 </table>	 </td>"	 );    }   ?>    </tr>   </table></div><!--============================--><!--==end main section of page==--><!--============================--></body></html>

Thanks so much and here is my code

Link to comment
Share on other sites

Just flag the records as having been displayed. Then don't select them for page 2 results, etc. I can't quickly tell whether you're already doing that, but this is a solution.

Link to comment
Share on other sites

It will help you get answers quicker if you provide more information about what happens. What do you mean you "can't get the query to work"? Is there an error? What happens when you run it? You're not checking for SQL errors, that would be one thing to add. $result = mysqli_query($link, $query) or exit(mysqli_error($link));

Link to comment
Share on other sites

niche, thanks for the help, I don't know how to do what you're suggesting though I'm sorry justsomeguyYou're right, I forgot to post the errors. I get these two errors Warning: mysql_query() expects parameter 1 to be string, object given in /Library/WebServer/Documents/phpTestCode/web apps labs/Lab 10/catalogBeta2.php on line 386Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in /Library/WebServer/Documents/phpTestCode/web apps labs/Lab 10/catalogBeta2.php on line 388

Link to comment
Share on other sites

ok figured it out. Thanks so much for all your help!!! I ended up using a while loop and populating an array that I could index in a for loop. Again thanks so much for all of your help everyone! If you see anything I can do to make this code better please let me know! My code ended up like this:

<html><!--Release InformationRelease Version 2.0.0Release Notes:		  -page completely rewritten to take advantage of php--><?php#initialize and declare variables#where do I send the form?$formpath = ($_SERVER['PHP_SELF']);#table attributes$border=1;$edgewidth='15%';$tablealignment='centop';$tealign='cenmid';$visibility='hidden';#error reportingerror_reporting(E_ALL);ini_set('display_errors','1');$link = mysqli_connect('127.0.0.1:3306', 'root', '4pp1353c', 'storedatabase');#check connectionif (mysqli_connect_errno()){printf("Connect failed: %s\n", mysqli_connect_error());exit();}#define array$id = array();$Product_name = array();$shape = array();$size = array();$color = array();$price = array();$numberOfItems = array();$imageFilename = array();$shortDescription = array();$fullDescription = array();#query and search$query = "SELECT * FROM inventory ORDER by id ASC";#fill array$result = mysqli_query($link, $query);$numberOfResults = $result->num_rows;$i=0;while ($row = mysqli_fetch_assoc($result))  {   $id[$i] =$row['id'];   $Product_name[$i] =$row['Product_name'];   $shape[$i] =$row['shape'];   $size[$i] =$row['size'];   $color[$i] =$row['color'];   $price[$i] =$row['price'];   $numberOfItems[$i] =$row['numberOfItems'];   $imageFilename[$i] =$row['imageFilename'];   $shortDescription[$i] =$row['shortDescription'];   $fullDescription[$i] =$row['fullDescription'];   $i+=1;  }#variables$itemsperpage = 3;$itemsperrow = 3;$rowsperpage = $itemsperpage/$itemsperrow;$numberOfPages = ceil($numberOfResults/$itemsperpage);#page number attributes$maxPage = $numberOfResults/$itemsperpage;$previousButton;$nextButton;$pageFieldDefaultValue='Jump to Page';#------------------------------------$pageNumber;if(isset($_POST['pageNumber'])){$pageNumber = $_POST['pageNumber'];}else if(!isset($pageNumber)){$pageNumber=1;}#------------------------------------if($pageNumber==1){$previousButton='=X=X=X= Page '.($pageNumber);}else{$previousButton='<==Go to Page '.($pageNumber-1);}if($pageNumber==$maxPage){$nextButton='=X=X=X= Page '.($pageNumber);}else{$nextButton='Go to Page '.($pageNumber+1).'==>';}#items per pageif(!isset($_POST['itemsperpage'])){$itemsperpage=3;}else{$itemsperpage = $_POST['itemsperpage'];}?><head>  <title>Awesome Shape Store</title>   <style>/*sadly this is done without style*/   .centop    {	 text-align:center;	 vertical-align:top;    }   .cenmid    {	 text-align:center;	 vertical-align:middle;    }   .header    {	 font-family:"courier"	 text-align:center;	 vertical-align:top;	 font-size:250%;	 font-weight:bold;    }   .tiny    {	 font-family:"courier"	 text-align:center;	 vertical-align:top;	 font-size:75%;	 font-style:italic;    }  </style>  <script type='text/javascript'>/*make some magic*//*-========================================-*//*-- Initialization and Display Functions --*//*-========================================-*/   function onLoad()   {    pageNumber()   }    var timer = setTimer("",0); /* reset the timer for add to cart display or other messages */   function alertDisplay(d)   {    var time=2000;     document.getElementById("div_display").innerHTML=d;    clearTimeout(timer);    timer=setTimeout("document.getElementById('div_display').innerHTML=''", time);   }/*End Initialize and Display Functions*//*-===================-*//*-- Set hidden info --*//*-===================-*/   function invisibles()   {      if (document.getElementById('visibles').checked)    {	 document.getElementById('hide1').style.visibility = 'hidden';	 document.getElementById('hide2').style.visibility = 'hidden';    }    else    {	 document.getElementById('hide1').style.visibility = 'visible';	 document.getElementById('hide2').style.visibility = 'visible';    }   }     function itemspp(sel)   {    var items=27; //"<?php echo $numberOfResults; ?>";    var itemsperpage = sel.options[sel.selectedIndex].value;    //alert(itemsperpage);       if (items%itemsperpage != 0)    {document.getElementById('nop').innerHTML = (Math.floor(items/itemsperpage)+1);}    else {document.getElementById('nop').innerHTML = (items/itemsperpage);}       form.submit();   }/*-====================-*//*-- Action Functions --*//*-====================-*/   //when you add the php to this button id will be named with a php variable and the variable will be the item id   var cart = new Array();   function addToCart(input,form)   {    var i=parseInt(input.id);    if (typeof cart[i] !== 'undefined' && cart[i] != null)	 {cart[i] += 1;}    else {cart[i] = 1;}     alert(input.id + " is in your cart "+cart[i]+' times');      var itemName = input.id + "pn"    alertDisplay('A ' + document.getElementById(itemName).innerHTML + ' has been added to your cart');   }     function search(input,form)   {    //alert('You Searched for: ' + document.getElementById('searchField').value);    form.submit();   }     /*==-Page Number Function-==*/   function pageNumber(input,form)   {    //alert('You selected ' + input.id);    var maxPage = <?php echo $maxPage; ?>;    var p = parseInt(document.getElementById('pageNumber').value);   //input.id is numberField       if ((input.id == 'pageField') &&    (    (isNaN(document.getElementById('pageField').value)) ||    (parseFloat(document.getElementById('pageField').value) % 1 !== 0) ||    (parseInt(document.getElementById('pageField').value) < 1) ||    (parseInt(document.getElementById('pageField').value) > <?php echo $maxPage; ?>)    ))    {	 alert('I\'m Sorry, ' + document.getElementById('pageField').value + '\ is not a valid page number. \nYou will be returned to page ' + document.getElementById('pageNumber').value);    }    else if (input.id == 'pageField')    {	 document.getElementById('pageNumber').value = parseInt(document.getElementById('pageField').value);    }//input.id is previousPage    else if (input.id == 'previousPage' && p <= 1)    {	 alertDisplay('You are already on page ' + p);	 return;    }    else if (input.id == 'previousPage')    {	 p -= 1;	 document.getElementById('pageNumber').value = p;    }//input.id is nextPage    else if (input.id == 'nextPage' && p >= <?php echo $maxPage; ?>)    {	 alertDisplay('You are on the last page.');	 return;    }    else if (input.id == 'nextPage')    {	 p += 1;	 document.getElementById('pageNumber').value = p;    }    else {alert('pageNumber Error');}    form.submit();   }   /*-===================================-*//*-- Button and Keystroke Submission --*//*-===================================-*/   function buttonSubmit(button,form)   {    if (button.id == 'searchButton')    {	 search(button,form);    }    else if (button.id == 'previousPage' || button.id == 'nextPage')    {	 pageNumber(button,form);    }    else if (button.name == 'addToCart')    {	 //alert(button.name);	 addToCart(button,form);    }    else    {	 alert('button click error');	 alert(button.id);	 alert(form.name);    }   }   function keystrokeSubmit(textbox,e,form)   {    e = e? e : window.event;    var prskeyrtrn = e.keyCode? e.keyCode : e.which? e.which : e.charCode? e.charCode :null;    if (prskeyrtrn == 13 && textbox.id == 'searchField') 	 {	  search(textbox,form);	 }    else if (prskeyrtrn == 13 && textbox.id == 'pageField')	 {	  pageNumber(textbox,form);	 }    else{}    }  </script></head> <body onLoad="onLoad()"><!--=====================--><!--==begin top of page==--><!--=====================--><form name="headForm" id="headForm"  method="POST" action="<?php echo $formpath; ?>">  <table width="100%" class="<?php echo $tablealignment; ?>" border="<?php echo $border; ?>">   <tr class="<?php echo $tealign; ?>"><!--left side of head -->    <td width="<?php echo $edgewidth; ?>">	 <table height="90" border="<?php echo $border; ?>" class="<?php echo $tablealignment; ?>" width="100%">	  <tr class="<?php echo $tealign; ?>"><td><div name="pagediv" id="pagediv">Current Page: <?php echo $pageNumber; ?></div></td></tr>	  <tr class="<?php echo $tealign; ?>"><td><input type="text" id="pageField" name="pageField" placeholder="<?php echo $pageFieldDefaultValue; ?>" onkeypress="keystrokeSubmit(this,event,form)"></td></tr>	  <tr class="<?php echo $tealign; ?>"><td><input style="cursor:pointer" type="button" id="previousPage" name="previousPage" value="<?php echo $previousButton; ?>" onclick="buttonSubmit(this,form);"></td></tr>	 </table>    </td><!--center of head -->    <td class="<?php echo $tealign; ?>" width="80%">		 <table height="90" border="<?php echo $border; ?>" class="<?php echo $tablealignment; ?>" width="100%">							  <tr class="header"><td height="10%">Awesome Shape Store Catalog</td></tr>							  <tr class="<?php echo $tealign; ?>"><td height="90%"><div id="div_display" class="centop"></div></td></tr>						 </table>				    </td><!--right side of head -->    <td width="<?php echo $edgewidth; ?>">	 <table height="90" border="<?php echo $border; ?>" class="<?php echo $tablealignment; ?>" width="100%">	  <tr class="<?php echo $tealign; ?>"><td><input type="text" id="searchField" name="searchField" placeholder="Search" onkeypress="keystrokeSubmit(this,event,form)"></td></tr>	  <tr class="<?php echo $tealign; ?>"><td><input style="cursor:pointer" type="button" id="searchButton" name="searchButton" value="Awesome Search" onclick="buttonSubmit(this,form);"></td></tr>	  <tr class="<?php echo $tealign; ?>"><td><input style="cursor:pointer" type="button" id="nextPage" name="nextPage" value="<?php echo $nextButton; ?>" onclick="buttonSubmit(this,form);"></td></tr>	 </table>    </td>   </tr>  </table><!--This is an invisible table and it holds the pageNumber-->  <table class="tiny" border="<?php echo $border; ?>">   <tr>    <td>	 Page Display Attributes:    </td>    <td colspan="2">	 <input type="checkbox" checked name="visibles" id="visibles" value="show invisibles" onclick="invisibles();">    </td>   </tr>   <tr style="visibility:hidden" name="hideFields" id="hide1">    <td>Current page number</td>    <td>Items per page:</td>    <td>Number of pages:</td>   </tr>   <tr style="visibility:hidden" name="hideFields"id="hide2">    <td><input type="text" id="pageNumber" name="pageNumber" value="<?php echo $pageNumber; ?>"></td>    <td>	 <?php echo $itemsperpage; ?><!--	 <select id="itemsperpage" name="itemsperpage" onchange="itemspp(this);">	  <option value="1">1 item</option>	  <option value="3" selected="selected">3 items</option>	  <option value="6">6 items</option>	  <option value="9">9 items</option>	  <option value="18">18  items</option>	  <option value="27">all items</option>	 </select>-->    </td>    <td><div name="nop" id="nop"><?php echo $numberOfPages; ?></div></td>   </tr>  </table></form><!--===================--><!--==end top of page==--><!--===================--> <!--=====	 This is a seperator	 ==========	 This is a seperator	 ==========	 This is a seperator	 =====--><!--=====	 This is a seperator	 ==========	 This is a seperator	 ==========	 This is a seperator	 =====--><!--=====	 This is a seperator	 ==========	 This is a seperator	 ==========	 This is a seperator	 =====--> <!--==============================--><!--==begin main section of page==--><!--==============================--><div name="divbody' id="divbody">   <table>   <?php    echo "<tr>";    for ($r=(($pageNumber-1)*3); $r<=((($pageNumber-1)*3)+2); $r++)       {	 echo"	  <td>	  <table>	  <tr>	  <!--catalog image-->	   <td valign='top'><img src='http://localhost/phpTestCode/web%20apps%20labs/Lab%2010/".$imageFilename[$r]."'></td>	   <td><table>	    <tr>	    <!--catalog id-->		 <td valign='top'><b>Item ID:</b></td>		 <td>".$id[$r]."</td>	    </tr>	    <tr>	    <!--catalog name-->		 <td valign='top'><b>Item Name:</b></td>		 <td id='".$id[$r]."pn'>".$Product_name[$r]."</td>	    </tr>	    <tr>	    <!--catalog shape-->  		 <td valign='top'><b>Shape:</b></td>		 <td>".$shape[$r]."</td>	    </tr>	    <tr>	    <!--catalog size-->		 <td valign='top'><b>Size:</b></td>		 <td>".$size[$r]."</td>	    </tr>	    <tr>	    <!--catalog color-->		 <td valign='top'><b>Color:</b></td>		 <td><font color=".$color[$r].">".$color[$r]."</td>	    </tr>	    <tr>	    <!--catalog price-->		 <td valign='top'><b>Price:</b></td>		 <td>$".$price[$r]."</td>	    </tr>	    <tr>	    <!--catalog description-->		 <td valign='top'><b>Description:</b></td>		 <td> This is an amazing".$size[$r]." <font color=".$color[$r]."><b>".$color[$r]."</b></font> ".$shape[$r]." with a super cool black border</td>	    </tr>  	   </table></td>	  </tr>	 <!--add to cart button-->	 <!--id set by php-->	 <!--<form name='addToCart' method='POST'action=". $formpath ."'>-->	  <tr><td><input type='button' value='Add to Cart' name='addToCart' id='".$id[$r]."' onclick='buttonSubmit(this,form);'></td></tr>	 <!--</form>-->		 </table>	 </td>	 ";    }    echo "</tr>";   ?>   </table></div><!--============================--><!--==end main section of page==--><!--============================--></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...