Product Problem!
Posted: Tue Aug 10, 2004 9:28 pm
I am having a problem in my script where I am posting values from the previous form. The problem is when the administrator adds a new product it uses ALTER to add a new column to the database but I am finding it hard to adjust to my query. For example if two products were in the database table the $string variable would look like:
$string is used as the actual main query. Like:
The problem is if the admin adds a new product the query has to detect that the new column exists. For example the original query would then become:
The other problem is determining which data has to be passed. The above examples uses $value for each element which only posts one value and spaws each column. The main code go's like:
I apologise for the bad explination, any help appreciated though!
Regards
Joe
Code: Select all
$string = "'$fullname','$value','$value'";Code: Select all
$nextsql = "INSERT INTO dbproductsinline VALUES(".$string.")";Code: Select all
$string = "'$fullname','$value','$value','$value'";Code: Select all
$sql1 = "SELECT * FROM dbproducts";
$result = mysql_query($sql1) or die(mysql_error());
while (true)
{
$row = mysql_fetch_assoc($result);
if ($row == false) break;
$val = $row['product'];
$val1 = str_replace(" ","-",$val);
$value = $_POST[$val1];
$string = "'$fullname','$value','$value'";
}
$nextsql = "INSERT INTO dbproductsinline VALUES(".$string.")";
mysql_query($nextsql) or die(mysql_error());Regards
Joe