I have two problems relating to one script. I have a table called suppliers with a supplierid in, I want update the prices for the services they offer in another table - supplierprices. The link between the two tablesis supplierid. Hopefully this will help with the following code:
At this point I have run a select statement and all the details have been selected ok:
Now we have some html generated based on certain criteria -
Code: Select all
if (($serviceprice1 == "true")){
echo "<tr><td><br>Your price for service 1is: £$serviceprice1 use this field to update your price:</tr></td><tr><td><input type=\"text\" name=\"serviceprice1\" value=\"\" maxlength=\"25\"></tr></td><br/>";
}
else{
echo "<br>You do not provide service1<br/>";
}Code: Select all
if(isset($_POST['submit']))
{
$supplierid = isset($_POST['supplierid']) ? $_POST['supplierid'] : "";
$serviceprice1 = isset($_POST['serviceprice1']) ? $_POST['serviceprice1'] : "";Now to update the supplierprices table
Code: Select all
$query = "INSERT INTO supplierprices (supplierid, service1price) values ($supplierid, $serviceprice1) ON DUPLICATE KEY UPDATE supplierid = '" . $supplierid . "'";When I run this query the supplierid is empty alog with any values I enter.
So I have two problems, the first is in the html that is generated, when I hit submit the query is empty of any values for service1price. In order to test I added a field below the php in html for service1price and it adds the value to the query.
The second problem is that when the query is run the supplierid is empty which means (if you look at the query) it cannot update the database.
I have got myself in a real fix, any ideas very welcome!
G