e1seix Posted June 2, 2008 Share Posted June 2, 2008 Look at me, back with another question already - what am I like? Any clues as to this one: if($product_id!=$product_id150){ print $product_name.'<br />'; echo '<form method="post">'; echo 'brand <input name="brand"><br />'; echo 'name <input name="name" value="'.$product_name.'"><br />'; echo 'brandID <input name="brandID"><br />'; echo 'sku <input name="sku"><br />'; echo 'cat <input name="cat"><br />'; echo 'subCat <input name="subCat"><br />'; echo 'dataID <input name="dataID" value="150"><br />'; echo 'dataCode <input name="dataCode" value="'.$product_id.'"><br />'; echo '<input type="submit">'; echo '</form>'; mysql_query("INSERT INTO admin (brand, name, brandID, sku, cat, subCat, dataID, dataCode) VALUES ('$_POST[brand]', '$_POST[name]', '$_POST[brandID]', '$_POST[sku]', '$_POST[cat]', '$_POST[subCat]', '$_POST[dataID]', '$_POST[dataCode]')"); } This is capturing data from datafeeds not already in my database, pre-populating the form for adjustment before I click on the submit button that will insert the data into the database. But it's not working. I'm wondering if it's something to do with it already being within another loop. Forms an loops are NOT my forté so any help is appreciated... Cheers Link to comment https://forums.phpfreaks.com/topic/108432-insert-into-form-issue/ Share on other sites More sharing options...
BlueSkyIS Posted June 2, 2008 Share Posted June 2, 2008 what's 'not working'? you probably want to check for SQL errors: mysql_query("INSERT INTO admin (brand, name, brandID, sku, cat, subCat, dataID, dataCode) VALUES ('$_POST[brand]', '$_POST[name]', '$_POST[brandID]', '$_POST[sku]', '$_POST[cat]', '$_POST[subCat]', '$_POST[dataID]', '$_POST[dataCode]')") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/108432-insert-into-form-issue/#findComment-555870 Share on other sites More sharing options...
e1seix Posted June 2, 2008 Author Share Posted June 2, 2008 what's 'not working'? you probably want to check for SQL errors: mysql_query("INSERT INTO admin (brand, name, brandID, sku, cat, subCat, dataID, dataCode) VALUES ('$_POST[brand]', '$_POST[name]', '$_POST[brandID]', '$_POST[sku]', '$_POST[cat]', '$_POST[subCat]', '$_POST[dataID]', '$_POST[dataCode]')") or die(mysql_error()); The INSERT INTO code itself doesn't work here's the whole code to make more sense of it $qry150=mysql_query("SELECT * FROM admin WHERE dataID='150'")or die(mysql_error()); while ($row = mysql_fetch_array($qry150)) { $sku=$row[sku]; $dataID=$row[dataID]; $dataCode=$row[dataCode]; } $xml = simplexml_load_file('http://content.webgains.com/affiliates/datafeed.html?action=download&campaign=xxxxx&[email protected]&password=xxxxxxxx&format=xml&zipformat=none&fields=standard&programs=150&categories=1944'); foreach ($xml->xpath('//product') as $character) { $product_id= $character->product_id; $product_name = $character->product_name; $fetch150=mysql_query("SELECT * FROM admin WHERE dataID='150' AND dataCode='$product_id' ORDER BY brand")or die(mysql_error()); while ($row = mysql_fetch_array($fetch150)) { $product_id150=$row[dataCode]; } if($product_id!=$product_id150){ print $product_name.'<br />'; echo '<form method="post">'; echo 'brand <input name="brand"><br />'; echo 'name <input name="name" value="'.$product_name.'"><br />'; echo 'brandID <input name="brandID"><br />'; echo 'sku <input name="sku"><br />'; echo 'cat <input name="cat"><br />'; echo 'subCat <input name="subCat"><br />'; echo 'dataID <input name="dataID" value="150"><br />'; echo 'dataCode <input name="dataCode" value="'.$product_id.'"><br />'; echo '<input type="submit">'; echo '</form>'; mysql_query("INSERT INTO admin (brand, name, brandID, sku, cat, subCat, dataID, dataCode) VALUES ('$_POST[brand]', '$_POST[name]', '$_POST[brandID]', '$_POST[sku]', '$_POST[cat]', '$_POST[subCat]', '$_POST[dataID]', '$_POST[dataCode]')"); } } Link to comment https://forums.phpfreaks.com/topic/108432-insert-into-form-issue/#findComment-555882 Share on other sites More sharing options...
BlueSkyIS Posted June 2, 2008 Share Posted June 2, 2008 you probably want to check for SQL errors: mysql_query("INSERT INTO admin (brand, name, brandID, sku, cat, subCat, dataID, dataCode) VALUES ('$_POST[brand]', '$_POST[name]', '$_POST[brandID]', '$_POST[sku]', '$_POST[cat]', '$_POST[subCat]', '$_POST[dataID]', '$_POST[dataCode]')") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/108432-insert-into-form-issue/#findComment-555884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.