zeusthegreat Posted October 17, 2011 Report Share Posted October 17, 2011 I have a index page <?php // Run a select query to get my latest 6 items //Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 6"); $productCount = mysql_num_rows($sql);//count the the output ammount if ($productCount > 0){ while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $price = $row["price"]; $details = $row["details"]; $product_name = $row["product_name"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_Added"])); // Notice here how we changed it from _added to _Added $dynamicList .= '<table width="100%" cellpadding="6"> <tr> <td width="34%" valign="top"><a href="product.php?"><img style="border: #666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="$product_name" width="120" height="113" border="1" /></a></td> <td width="66%" valign="top"><p> ' . $product_name . '<br /> £ ' . $price . '<br /> ' . $details . '<br /> <a href="product.php?id=">View product</a></p></td> </tr> </table>'; } }else{ $dynamicList = "We have no products listed in our store Yet"; } mysql_close(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">'>http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Store </title> <link rel="stylesheet" href="style/style.css" type="text/css" media="screen" /> <script type="text/javascript"> function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('style/home-grey.gif','style/web-design-grey.gif','style/web-development-grey.gif','style/e-commerce-grey.gif','style/pricing-grey.gif')"> <div align="center" id="outerMainWrapper"> <div align="center" id="mainWrapper"> <?php include_once("template_Header.php");?> <div id="headerNav"><table width="100%"> <tr> </tr> <tr> <td><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('HOME','','style/home-grey.gif',1)"><img src="style/home.gif" alt="HOME" name="HOME" width="170" height="34" border="0" id="HOME" /></a></td> <td><a href="web-design.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('WEB DESIGN','','style/web-design-grey.gif',1)"><img src="style/web-design.gif" alt="WEB DESIGN" name="WEB DESIGN" width="170" height="34" border="0" id="WEB DESIGN" /></a></td> <td><a href="web-development.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('WEB DEVELOPMENT','','style/web-development-grey.gif',1)"><img src="style/web-development.gif" alt="WEB DEVELOPMENT" name="WEB DEVELOPMENT" width="170" height="34" border="0" id="WEB DEVELOPMENT" /></a></td> <td><a href="e-commerce.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('E COMMERCE','','style/e-commerce-grey.gif',1)"><img src="style/e-commerce.gif" alt="E COMMERCE" name="E COMMERCE" width="170" height="34" border="0" id="E COMMERCE" /></a></td> <td><a href="pricing.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('PRICING','','style/pricing-grey.gif',1)"><img src="style/pricing.gif" alt="PRICING" name="PRICING" width="170" height="34" border="0" id="PRICING" /></a></td> </tr> <tr> </tr> </table> </div> <?php include_once("template_Sidebar.php");?> </div> <div align="left" id="pageContent"><table width="98%"> <tr> <td width="25%" valign="top">Template</td> <td width="49%" valign="top"><p>Newest Items added to the store</p> <p><?php echo $dynamicList; ?></p> <!--<table width="100%" cellpadding="6"> <tr> <td width="34%" valign="top"><a href="product.php?"><img style="border: #666 1px solid;" src="inventory_images/21.jpg" alt="$dynamicTitle" width="120" height="113" border="1" /></a></td> <td width="66%" valign="top"><p>product Title<br /> product price<br /> product details<br /> <a href="product.php?">View product</a></p></td> </tr> </table> --> <p> </p> <!--<table width="92%" height="106" cellpadding="4"> <tr valign="top"> <td width="23%"><img src="../Picture1.gif" width="1" height="1" /><img src="../Picture1.gif" width="1" height="1" alt="$dynamicTitle" /><a href="product.php?"><img style="border-color: #999" src="inventory_images/21.jpg" alt="$dynamicTitle" width="70" height="70" border="1" /></a></td> <td width="77%"><p>product title<br /> product price<br /> product details <br /> <a href="Product.php">View product</a></p></td> </tr> </table> --> <p> </p> <p> </p> <p> </p> <p> </p></td> <td width="26%" valign="top">Large templates</td> </tr> </table> </div> <?php include_once("template_Footer.php");?> </div> </div> </body> </html> which shows the items in my db bo problem then i also have a product page which supposed to show a bigger version of the image product.php <?php error_reporting(E_ALL); ini_set('display_errors', '1'); ?> <?php // Check to see the URL variable is set and that it exists in the database if (isset($_GET['id'])) { // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $id = preg_replace('#[^0-9]#i','', $_GET['id']); // Use this var to check to see if this ID exists, if yes then get the product // details, if no then exit this script and give message why $sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { // get all the product details while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $details = $row["details"]; $category = $row["category"]; $subcategory = $row["subcategory"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_Added"])); } } else { echo "That item does not exist."; exit(); } } else { echo "Data to render this page is missing."; exit(); } ?> !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" /> <title><?php echo $product_name; ?></title> <link rel="stylesheet" href="style/style.css" type="text/css" media="screen" /> </head> <body> <div align="center"></div> <div align="center" id="mainWrapper"> <?php include_once("template_header.php"); ?> <?php include_once("template_sidebar.php"); ?> <<div id="pageContent"> <table width="100%" border="0" cellspacing="0" cellpadding="15"> <tr> <td width="19%" valign="top"><img src="inventory_images/<?php echo $id; ?>.jpg" width="142" height="188" alt="<?php echo $product_name; ?>" /><br /> <a href="inventory_images/<?php echo $id; ?>.jpg">View Full Size Image</a></td> <td width="81%" valign="top"><h3><?php echo $product_name; ?></h3> <?php echo "$subcategory $category"; ?> <br /> <p><?php echo "$".$price; ?><br /> <br /> <br /> <?php echo $details; ?> <br /> </p> <form id="form1" name="form1" method="post" action="cart.php"> <input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" /> <input type="submit" name="button" id="button" value="Add to Shopping Cart" /> </form> </td> </tr> </table> </div> <?php include_once("template_footer.php");?> </div> </body> </html> i have even called the bigger image the exact product name of the item but when i try to view product.php it says data to render this page is missing and when i click the link for the item that appears on the index page it says that item does not exist thanks in advance 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.
Note: Your post will require moderator approval before it will be visible.