[SOLVED] amend database entry through CMS
Posted: Tue Mar 22, 2005 3:51 am
any suggestions on this would be greatly appreciated! thanks.
i have a simple add product, delete product and amend product CMS. the 'amend product' is where i am having issues, specifically in the way a form is populated with information from a database.
the database is made up of 2 tables: 'products' and 'cats'.
the user has the option to change a product category. the product category is a numerical reference in the 'products' table. the number has a corresponding description in a 'cats' table. currently the form displays the numercial reference - i would like it to display the description from the 'cats' table.
here is the 'amend' code:
i think this may have something to do with relational tables? any tutorials or pointers would be v.useful! thanks!
feyd | Please review how to post code using
i have a simple add product, delete product and amend product CMS. the 'amend product' is where i am having issues, specifically in the way a form is populated with information from a database.
the database is made up of 2 tables: 'products' and 'cats'.
the user has the option to change a product category. the product category is a numerical reference in the 'products' table. the number has a corresponding description in a 'cats' table. currently the form displays the numercial reference - i would like it to display the description from the 'cats' table.
here is the 'amend' code:
Code: Select all
$id = $_GET["id"];
$dbconn = mysql_connect("","","");
mysql_select_db("");
$sql ="SELECT * FROM products WHERE productID = '$id'";
$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
$row = mysql_fetch_array($result);
?>
<html>
<head>
<title>Amend a Product</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="adminstyles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
echo"<h1>Amend a Product</h1>";
echo"<form name=\"form\" id=\"form\" method=\"post\" action=\"dbamend.php?id=$id\">";
echo"<select name=\"catID\" id=\"catID\">";
echo"<option selected value=\"" .$row["catID"]. "\">" .$row["catID"]. "</option>";
echo"<option>Beds & bedsteads</option>";
echo"<option>Sofa beds</option>";
echo"<option>Children's furniture</option>";
echo"<option>Mattresses</option>";
echo"<option>Bedroom furniture</option>";
echo"<option>Headboards</option>";
echo"</select>";feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]