
lill77
Members-
Posts
29 -
Joined
-
Last visited
Never
Everything posted by lill77
-
php code insert ino product ?? changes al products ??
lill77 replied to lill77's topic in PHP Coding Help
Hello I have a problem that updates every product in my database when i add a new 1 to the the new product details. Can anyone help? Thanks Code is below New product page <?php include 'db.php'; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $sql = "INSERT INTO `products` (`category_id` , `title` , `size` , `description` , `image` , `imageenlarge`) VALUES ( '', '$title', '$size', '$description' , '', '');"; $sql_query = mysql_query($sql) or die (mysql_error()); $sql = "SELECT LAST_INSERT_ID()"; $result = mysql_query($sql); $row = mysql_fetch_row($result); $product_id = $row[0]; // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> <META HTTP-EQUIV=Refresh CONTENT='0; URL=index.php?page=edit-product.php&product=<? echo $product_id; ?>'> <p align="center" class="smalltext style2 style1">Saving Changes</p> Update Product <? include 'db.php' ?> <? // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $sql_query = mysql_query("UPDATE `products` SET `title` = '".$_REQUEST['title']."', `size` = '".$_REQUEST['size']."', `description` = '".$_REQUEST['description']."', `category_id` = ".$_REQUEST['category_id'].", `Image` = '".$_REQUEST['image']."', `Imageenlarge` = '".$_REQUEST['imageenlarge']."'") or die (mysql_error()); // close connection mysql_close($connection); ?> <META HTTP-EQUIV=Refresh CONTENT="0; URL=index.php?page=products.php"> Edit page <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <? include 'db.php' ?> <script language="javascript" type="text/javascript"><!-- function popupWindow(url, width, height) { if(width == null){ width =450; } if(height == null){height =150;} window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=100') } //--></script> <script> function log_out() { return confirm('Are you sure you want to Delete this article?'); } </script> <?php // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM `products` WHERE `ID` = '".$_REQUEST['product']."'"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $row = mysql_fetch_row($result); $CurrentProduct = $row[0]; // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> <body> <form method="GET" action="update-product.php"> <div align="center"> <table width="505" border="0" cellpadding="2" cellspacing="2" bordercolor="#FFFFFF" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0" id="table1"> <tr> <td width="130" align="right"><b> <font face="Arial" size="2" color="#808080">Product ID:</font></b></td> <td width="228" align="center"> <p align="left"> <? echo "$row[0]" ?> <input name="ID" type="hidden" id="ID" value="<? echo "$row[0]" ?>" /> </p> </td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"><b> <font face="Arial" size="2" color="#808080">Title:</font></b></td> <td align="center"> <div align="left"> <input type="text" name="title" size="36" value="<? echo "$row[2]" ?>" ?> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130"><div align="right"><b><font face="Arial" size="2" color="#808080">Sizes </font></b></div></td> <td align="center"><div align="left"> <input type="text" name="size" size="36" value="<? echo "$row[3]" ?>" ? /><br /> (Format: <b>Small/Medium/Large</b>) </div></td> <td width="127"> </td> </tr> <tr> <td width="130" align="right"><b><font face="Arial" size="2" color="#808080">Description:</font></b></td> <td align="center"><div align="left"> <textarea name="description" cols="50" rows="10" id="description"><? echo "$row[4]" ?></textarea> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"><b><font face="Arial" size="2" color="#808080">Category:</font></b></td> <td align="center"><div align="left"> <p> </p> <p><select name="category_id" id="category_id"> <?php $currentcat = $row[1]; // set database server access variables: // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM `category`;"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes // print them one after another while($row = mysql_fetch_row($result)) { echo "<option value=\"".$row[0]."\""; if ($row[0]==$currentcat) {echo " Selected";}; echo ">$row[1]</option>"; } } // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> </select> </p> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"><b><font face="Arial" size="2" color="#808080">Image:</font></b></td> <td align="center"><div align="left"> <select name="image" id="image"> <option value="noimage.png">No Image</option> <?php if ($handle = opendir('../productimages/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $page_name = $file; //$page_name=substr($file, 0, strpos($file, ".")); echo "<option"; if($page_name==$row[5]){echo ' selected';}; echo ">$page_name</option>"; } } } closedir($handle); ?> </select> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td align="right"><b><font face="Arial" size="2" color="#808080">Enlarge Image:</font></b></td> <td align="center"><div align="left"> <select name="imageenlarge" id="imageenlarge"> <option value="noimage.png">No Image</option> <?php if ($handle = opendir('../productimages/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $page_name = $file; //$page_name=substr($file, 0, strpos($file, ".")); echo "<option"; if($page_name==$row[6]){echo ' selected';}; echo ">$page_name</option>"; } } } closedir($handle); ?> </select> </div></td> <td align="right"> </td> </tr> <tr> <td width="130" align="right"> </td> <td align="center"><div align="left"></div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130"> </td> <td align="center"><div align="left"></div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"> </td> <td align="center"> </td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"> </td> <td align="center"> </td> <td width="127" align="right"> </td> </tr> <tr> <td width="130"> </td> <td align="center"> </td> <td width="127" align="right"> </td> </tr> <tr> <td> </td> <td align="center"> </td> <td> </td> </tr> </table> </div> <p align="center"><input type="submit" value="Save" name="B1"> <input type="reset" value="Close" name="B2" onclick="history.back()"> </p> </form> </p> <p align="center"> </p> </body> </html> -
Great thanks for your help, I will have a go and see if i can do it ? Rich
-
php code insert ino product ?? changes al products ??
lill77 replied to lill77's topic in PHP Coding Help
Hello anybody out there who can help me with this \?? :'( :'( When i add a new product it changes all in my database to the details i just added ?? Rich -
php code insert ino product ?? changes al products ??
lill77 replied to lill77's topic in PHP Coding Help
Hi again.. bit lost now. I have new product pages as below <?php include 'db.php'; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $sql = "INSERT INTO `products` (`category_id` , `title` , `size` , `description` , `image` , `imageenlarge`) VALUES ( '', '$title', '$size', '$description' , '', '');"; $sql_query = mysql_query($sql) or die (mysql_error()); $sql = "SELECT LAST_INSERT_ID()"; $result = mysql_query($sql); $row = mysql_fetch_row($result); $product_id = $row[0]; // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> <META HTTP-EQUIV=Refresh CONTENT='0; URL=index.php?page=edit-product.php&product=<? echo $product_id; ?>'> <p align="center" class="smalltext style2 style1">Saving Changes</p> and also the edit page, then as below the update product <? include 'db.php' ?> <? // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $sql_query = mysql_query("UPDATE `products` SET `title` = '".$_REQUEST['title']."', `size` = '".$_REQUEST['size']."', `description` = '".$_REQUEST['description']."', `category_id` = ".$_REQUEST['category_id'].", `Image` = '".$_REQUEST['image']."', `Imageenlarge` = '".$_REQUEST['imageenlarge']."'") or die (mysql_error()); // close connection mysql_close($connection); ?> <META HTTP-EQUIV=Refresh CONTENT="0; URL=index.php?page=products.php"> -
Hello thanks where abouts in the code should this be entered. . . ??
-
php code insert ino product ?? changes al products ??
lill77 replied to lill77's topic in PHP Coding Help
What should I be doing then ? This code if from the edit-product.php. Thanks -
Hello when i insert a new product ino my database it changes all exsisitng products to the same as the new one ??? Ive llloked at the code i have and cant see where the problem is ?? <?php include 'db.php'; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $sql = "INSERT INTO `products` (`category_id` , `title` , `size` , `description` , `image` , `imageenlarge`) VALUES ( '', '', 'size', '' , 'noimage.png', 'noimage_big.png');"; $reult = mysql_query($sql) or die (mysql_error()); $product_id = mysql_insert_id(); // close connection mysql_close($connection); ?> <META HTTP-EQUIV=Refresh CONTENT='0; URL=index.php?page=edit-product.php&product=<? echo $product_id; ?>'> <p align="center" class="smalltext style2 style1">Saving Changes</p> <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <? include 'db.php' ?> <script language="javascript" type="text/javascript"><!-- function popupWindow(url, width, height) { if(width == null){ width =450; } if(height == null){height =150;} window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=100') } //--></script> <script> function log_out() { return confirm('Are you sure you want to Delete this article?'); } </script> <?php // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM `products` WHERE `ID` = '".$_REQUEST['product']."'"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $row = mysql_fetch_row($result); $CurrentProduct = $row[0]; // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> <body> <form method="GET" action="update-product.php"> <div align="center"> <table width="505" border="0" cellpadding="2" cellspacing="2" bordercolor="#FFFFFF" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0" id="table1"> <tr> <td width="130" align="right"><b> <font face="Arial" size="2" color="#808080">Product ID:</font></b></td> <td width="228" align="center"> <p align="left"> <? echo "$row[0]" ?> <input name="ID" type="hidden" id="ID" value="<? echo "$row[0]" ?>" /> </p> </td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"><b> <font face="Arial" size="2" color="#808080">Title:</font></b></td> <td align="center"> <div align="left"> <input type="text" name="title" size="36" value="<? echo "$row[2]" ?>" ?> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130"><div align="right"><b><font face="Arial" size="2" color="#808080">Sizes </font></b></div></td> <td align="center"><div align="left"> <input type="text" name="size" size="36" value="<? echo "$row[3]" ?>" ? /><br /> (Format: <b>Small/Medium/Large</b>) </div></td> <td width="127"> </td> </tr> <tr> <td width="130" align="right"><b><font face="Arial" size="2" color="#808080">Description:</font></b></td> <td align="center"><div align="left"> <textarea name="description" cols="50" rows="10" id="description"><? echo "$row[4]" ?></textarea> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"><b><font face="Arial" size="2" color="#808080">Category:</font></b></td> <td align="center"><div align="left"> <p> </p> <p><select name="category_id" id="category_id"> <?php $currentcat = $row[1]; // set database server access variables: // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM `category`;"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes // print them one after another while($row = mysql_fetch_row($result)) { echo "<option value=\"".$row[0]."\""; if ($row[0]==$currentcat) {echo " Selected";}; echo ">$row[1]</option>"; } } // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> </select> </p> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"><b><font face="Arial" size="2" color="#808080">Image:</font></b></td> <td align="center"><div align="left"> <select name="image" id="image"> <option value="noimage.png">No Image</option> <?php if ($handle = opendir('../productimages/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $page_name = $file; //$page_name=substr($file, 0, strpos($file, ".")); echo "<option"; if($page_name==$row[5]){echo ' selected';}; echo ">$page_name</option>"; } } } closedir($handle); ?> </select> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td align="right"><b><font face="Arial" size="2" color="#808080">Enlarge Image:</font></b></td> <td align="center"><div align="left"> <select name="imageenlarge" id="imageenlarge"> <option value="noimage.png">No Image</option> <?php if ($handle = opendir('../productimages/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $page_name = $file; //$page_name=substr($file, 0, strpos($file, ".")); echo "<option"; if($page_name==$row[6]){echo ' selected';}; echo ">$page_name</option>"; } } } closedir($handle); ?> </select> </div></td> <td align="right"> </td> </tr> <tr> <td width="130" align="right"> </td> <td align="center"><div align="left"></div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130"> </td> <td align="center"><div align="left"></div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"> </td> <td align="center"> </td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"> </td> <td align="center"> </td> <td width="127" align="right"> </td> </tr> <tr> <td width="130"> </td> <td align="center"> </td> <td width="127" align="right"> </td> </tr> <tr> <td> </td> <td align="center"> </td> <td> </td> </tr> </table> </div> <p align="center"><input type="submit" value="Save" name="B1"> <input type="reset" value="Close" name="B2" onclick="history.back()"> </p> </form> </p> <p align="center"> </p> </body> </html>
-
Hello ive been helped before and am knew to this i really want to display products acroos the page by 4 then contnuing down by ABC.. My code is below can anybody shed some light for me. ??? ??? <?php include 'admin/db.php'; include 'header-home.php'; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM `products` ORDER BY 'CAT' ASC"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes // print them one after another while($row = mysql_fetch_array($result)) { echo "<tr><td align='left' valign='top'><a href='search.php?cat=$row[iD]'>$row[CAT]</a> </tr>"; } } else { // no // print status message echo "<p align='center'><font color='#808080' face='Arial'>No records found.</font></p>"; } // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> <?php // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query if (isset($_REQUEST['search'])) { $query = "SELECT * FROM products WHERE description LIKE '%".$_REQUEST['search']."%'"; } else if (isset($_REQUEST['cat'])) { $query = "SELECT * FROM products WHERE category_id = ".$_REQUEST['cat']." ORDER BY Title ASC"; } // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if ($num=mysql_num_rows($result) > 0) { // yes // print them one after another ECHO "<table width='90%' height='257' border='0'>"; while($row = mysql_fetch_array($result)) { ?> <p class="style13"> </p> <table width="168" border="0" align="center"> <tr> <td><div align="center"><span class="style13"><? echo $row['title']; ?></span></div></td> </tr> <tr> <td><a href='productimages/<?=$row[5];?> ' rel="lightbox"><img src="productimages/<?=$row[6];?>" width="133" height="180" /></td> </tr> <tr> <td><? echo $row['description']; ?> <div align="center"></div> <div align="center"></div></td> </tr> <tr> <td><div align="center"><span class="style6">Size: <? echo $row['size']; ?></span></div></td> </tr> </table> <p> </p></td> </tr><tr bgcolor="#6699FF"><td height="20" valign="top" bgcolor="#FFFFFF"> </td> </tr> <p> <? } } // free result set memory mysql_free_result($result); // close connection mysql_close($connection); include 'footer.php';?>
-
thanks again Rich
-
Thanks It is better the save the info into a field that is most common eg product, and then search by make ? Do you know of any links to how to do this eg. help or tutorial ?? Thanks for your help Rich
-
Hello im back again. So I gather that i can show products by type eg duvet set or fleece or pillow etc... and also show by make of the product, with the way im saving the info in my database. Thanks
-
Great thanks i WILL see how I go !
-
Im getting myself confussed. I need to save products by two ways cat and by product so it would be a Cushion that belongs to say . . M&S. So then I could pull the info in by product eg cushion and or by M&S. Thanks
-
Hello I think i want to display the products maybe 4 across the page and list by abc . . . Thanks
-
Thanks would that be someting like $query = "SELECT * FROM `products` ORDER BY 'CAT' ASC"; an $query = "SELECT * FROM `category` ORDER BY 'CAT' ASC"; ?
-
Hello can somebody help me please. . . I have created 2 tables in my phpMYADMIN im in version MySQL client version: 4.1.22. I have attached the two tables, I want to know if I can select info from them two ways by cat which will be make eg Ford, and by product eg Window or horn . . . Thanks [attachment deleted by admin]
-
Hello does not seem to!!
-
Hello Im trying to find the best way to pull in products by category into my page. i have the following code is this the best way or correct ? thanks <?php include 'admin/db.php'; include 'header-home.php'; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM `category` ORDER BY 'CAT' ASC"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes // print them one after another while($row = mysql_fetch_array($result)) { echo "<tr><td align='left' valign='top'><a href='search.php?cat=$row[iD]'>$row[CAT]</a> </tr>"; } } else { // no // print status message echo "<p align='center'><font color='#808080' face='Arial'>No records found.</font></p>"; } // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?>
-
thanks for your help ! Rich
-
Hello not quite there yet ? Im getting the follwoing error on page when I save the product Parse error: syntax error, unexpected ')', expecting ']' in /home/characte/public_html/test/admin/update-product.php on line 15 code below on update product page <? include 'db.php' ?> <? // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $sql_query = mysql_query("UPDATE `products` SET `title` = '".$_REQUEST['title']."', `size` = '".$_REQUEST['size']."', `description` = '".$_REQUEST['description']."', `category_id` = ".$_REQUEST['category_id'].", `Image` = '".$_REQUEST['image']."', `Imageenlarge` = '".$_REQUEST['imageenlarge') or die (mysql_error()); // close connection mysql_close($connection); ?> <META HTTP-EQUIV=Refresh CONTENT="0; URL=index.php?page=products.php">
-
Great thanks for your help im on my way now. Thanks Rich
-
Here you go, yes i think so !! <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <? include 'db.php' ?> <script language="javascript" type="text/javascript"><!-- function popupWindow(url, width, height) { if(width == null){ width =450; } if(height == null){height =150;} window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=100') } //--></script> <script> function log_out() { return confirm('Are you sure you want to Delete this article?'); } </script> <?php // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM `Products` WHERE `ID` = '".$_REQUEST['product']."'"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $row = mysql_fetch_row($result); $CurrentProduct = $row[0]; // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> <body> <form method="GET" action="update-product.php"> <div align="center"> <table width="505" border="0" cellpadding="2" cellspacing="2" bordercolor="#FFFFFF" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0" id="table1"> <tr> <td width="130" align="right"><b> <font face="Arial" size="2" color="#808080">Product ID:</font></b></td> <td width="228" align="center"> <p align="left"> <? echo "$row[0]" ?> <input name="ID" type="hidden" id="ID" value="<? echo "$row[0]" ?>" /> </p> </td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"><b> <font face="Arial" size="2" color="#808080">Title:</font></b></td> <td align="center"> <div align="left"> <input type="text" name="title" size="36" value="<? echo "$row[2]" ?>" ?> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130"><div align="right"><b><font face="Arial" size="2" color="#808080">Sizes </font></b></div></td> <td align="center"><div align="left"> <input type="text" name="size" size="36" value="<? echo "$row[3]" ?>" ? /><br /> (Format: <b>Small/Medium/Large</b>) </div></td> <td width="127"> </td> </tr> <tr> <td width="130" align="right"><b><font face="Arial" size="2" color="#808080">Description:</font></b></td> <td align="center"><div align="left"> <textarea name="description" cols="50" rows="10" id="description"><? echo "$row[4]" ?></textarea> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"><b><font face="Arial" size="2" color="#808080">Category:</font></b></td> <td align="center"><div align="left"> <p> </p> <p><select name="category_id" id="category_id"> <?php $currentcat = $row[4]; // set database server access variables: // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM `Category`;"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes // print them one after another while($row = mysql_fetch_row($result)) { echo "<option value=\"".$row[0]."\""; if ($row[0]==$currentcat) {echo " Selected";}; echo ">$row[1]</option>"; } } // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> </select> </p> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"><b><font face="Arial" size="2" color="#808080">Image:</font></b></td> <td align="center"><div align="left"> <select name="image" id="image"> <option value="noimage.png">No Image</option> <?php if ($handle = opendir('../productimages/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $page_name = $file; //$page_name=substr($file, 0, strpos($file, ".")); echo "<option"; if($page_name==$row[4]){echo ' selected';}; echo ">$page_name</option>"; } } } closedir($handle); ?> </select> </div></td> <td width="127" align="right"> </td> </tr> <tr> <td align="right"><b><font face="Arial" size="2" color="#808080">Enlarge Image:</font></b></td> <td align="center"><div align="left"> <select name="imageenlarge" id="imageenlarge"> <option value="noimage.png">No Image</option> <?php if ($handle = opendir('../productimages/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $page_name = $file; //$page_name=substr($file, 0, strpos($file, ".")); echo "<option"; if($page_name==$row[5]){echo ' selected';}; echo ">$page_name</option>"; } } } closedir($handle); ?> </select> </div></td> <td align="right"> </td> </tr> <tr> <td width="130" align="right"> </td> <td align="center"><div align="left"></div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130"> </td> <td align="center"><div align="left"></div></td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"> </td> <td align="center"> </td> <td width="127" align="right"> </td> </tr> <tr> <td width="130" align="right"> </td> <td align="center"> </td> <td width="127" align="right"> </td> </tr> <tr> <td width="130"> </td> <td align="center"> </td> <td width="127" align="right"> </td> </tr> <tr> <td> </td> <td align="center"> </td> <td> </td> </tr> </table> </div> <p align="center"><input type="submit" value="Save" name="B1"> <input type="reset" value="Close" name="B2" onclick="history.back()"> </p> </form> </p> <p align="center"> </p> </body> </html>
-
Hello sorry do you mean form mysql the error im getting is when im trying to add a product into my database using admin/index.php?page=edit-product.php&product=3 the error is http://www.characterworld.uk.com/test/admin/index.php?page=edit-product.php&product=3 Regards
-
Hello getting this error Error in query: SELECT * FROM `Products` WHERE `ID` = '3'. Table 'characte_characterworld.Products' doesn't exist Could it because of the code on my products.php page as below <? include 'db.php' ?> <?php // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); if ($sort ==""){ $sort = "title"; } // create query $query = "SELECT * FROM products, category WHERE category_id = category.ID ORDER BY $sort ASC"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes // print them one after another echo "<table align =center border=1 width=800 id=table1 cellspacing=2 cellpadding=2 style=border-collapse: collapse >"; echo "<tr>"; echo "<td bgcolor='#6699FF'><b><font face='Arial' color='#FFFFFF'> <a href='index.php?sort=productID'>ID</a> </font></b></td>"; echo "<td bgcolor='#6699FF'><b><font face='Arial' color='#FFFFFF'> <a href='index.php?sort=category_id'> Category </a></font></b></td>"; echo "<td bgcolor='#6699FF'><b><font face='Arial' color='#FFFFFF'> <a href='index.php?sort=title'> title </a></font></b></td>"; echo "<td bgcolor='#6699FF'><b><font face='Arial' color='#FFFFFF'> <a href='index.php?sort=size'> size </a></font></b></td>"; echo "<td bgcolor='#6699FF'><b><font face='Arial' color='#FFFFFF'> <a href='index.php?sort=description'> description </a> </font></b></td>"; echo "<td bgcolor='#6699FF'><b><font face='Arial' color='#FFFFFF'></font></b></td>"; echo "<td bgcolor='#6699FF'><b><font face='Arial' color='#FFFFFF'></font></b></td>"; echo "</tr>"; while($row = mysql_fetch_row($result)) { echo "<tr border=0>"; echo "<td>".$row[0]."</td>"; // id echo "<td>".$row[2]."</td>"; // title echo "<td>".$row[1]."</td>"; // title echo "<td>".$row[3]."</td>"; // size echo "<td>".substr($row[3], 0, 30)."...</td>"; // description echo "<td>".$row[7]."</td>"; // echo "<td><a href='?page=edit-product.php&product=$row[0]'>Edit</a></td>"; // echo "<td align = 'centre'><a href='delete-product.php?id=$row[0]' onclick='return log_out()'>Delete</a></td>"; echo "</tr>"; } echo "</table>"; } else { // no // print status message echo "<p align='center'><font color='#808080' face='Arial'>No records found.</font></p>"; } // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?>
-
Sorry am new to this here you go ? Thanks <?php include 'db.php'; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $sql = "INSERT INTO `products` (``, `category_id` , `title` , `size` , `description` , `image` , `imageenlarge`) VALUES ( '' , '', '', 'size', '' , 'noimage.png', 'noimage_big.png');"; $sql_query = mysql_query($sql) or die (mysql_error()); $sql = "SELECT LAST_INSERT_ID()"; $result = mysql_query($sql); $row = mysql_fetch_row($result); $product_id = $row[0]; // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?> <META HTTP-EQUIV=Refresh CONTENT='0; URL=index.php?page=edit-product.php&product=<? echo $product_id; ?>'> <p align="center" class="smalltext style2 style1">Saving Changes</p>