Hi guys,
Trying to update all values in a table within my database but cant get it to do any. Probably something silly i have done or left out.
I have a table that will be filled in and when submit is clicked the table should be updated with the new values.
There should only be one row of data in this table as it is a specification and will be reading the values out of the table later on.
Here is the Code:
I have only tried to update the first two values in the table to see if it would work.
Could anyone help please?
Thanks
Trying to update all values in a table within my database but cant get it to do any. Probably something silly i have done or left out.
I have a table that will be filled in and when submit is clicked the table should be updated with the new values.
There should only be one row of data in this table as it is a specification and will be reading the values out of the table later on.
Here is the Code:
Code:
<form id="test" action="SpecUpdateInsert.php" method="POST" name="SpecUpdate">
<table>
<tr>
<th scope="col">Sieves</th>
</tr>
<tr>
<th scope="row">+163µm</th>
<td><input name="S1TS1" type="text" id="S1TS1" size="12" maxlength="12" /></td>
<td><input name="S1TS2" type="text" id="S1TS2" size="12" maxlength="12" /></td>
</tr>
<tr>
<th scope="row">-63µm</th>
<td><input name="S2TS1" type="text" id="S2TS1" size="12" maxlength="12" /></td>
<td><input name="S2TS2" type="text" id="S2TS2" size="12" maxlength="12" /></td>
</tr>
<tr>
<th scope="col">Sieves</th>
</tr>
<tr>
<th scope="row">+163µm</th>
<td><input name="S1NC1" type="text" id="S1NC1" size="12" maxlength="12" /></td>
<td><input name="S1NC2" type="text" id="S1NC2" size="12" maxlength="12" /></td>
<td><input name="S1NC3" type="text" id="S1NC3" size="12" maxlength="12" /></td>
<td><input name="S1NC4" type="text" id="S1NC4" size="12" maxlength="12" /></td>
</tr>
<tr>
<th scope="row">-63µm</th>
<td><input name="S2NC1" type="text" id="S2NC1" size="12" maxlength="12" /></td>
<td><input name="S2NC2" type="text" id="S2NC2" size="12" maxlength="12" /></td>
<td><input name="S2NC1" type="text" id="S2NC1" size="12" maxlength="12" /></td>
<td><input name="S2NC2" type="text" id="S2NC2" size="12" maxlength="12" /></td>
</tr>
</table>
<input type="hidden" name="submitted" value="1">
<input name="SpecUpdateInsert" type="submit" id="SpecUpdateInsert" value="Submit Testing";/>
<input name="Reset Fields" type="reset" value="Reset Fields" />
</form>
Code:
if($_POST['submitted']==1){
$S1TS1 = mysql_real_escape_string($_POST['S1TS1']);
$S1TS2 = preg_replace('/[^0-9]/', '',$_POST['S1TS2']);
$S1NC1 = mysql_real_escape_string($_POST['S1NC1']);
$S1NC2 = preg_replace('/[^0-9\.]/', '', $_POST['S1NC2']);
$S1NC3 = preg_replace('/[^0-9\.]/', '', $_POST['S1NC3']);
$S1NC4 = preg_replace('/[^0-9\.]/', '', $_POST['S1NC4']);
$S2TS1 = preg_replace('/[^0-9\.]/', '', $_POST['S2TS1']);
$S2TS2 = preg_replace('/[^0-9\.]/', '', $_POST['S2TS2']);
$S2NC1 = preg_replace('/[^0-9\.]/', '', $_POST['S2NC1']);
$S2NC2 = preg_replace('/[^0-9\.]/', '', $_POST['S2NC2']);
$S2NC3 = preg_replace('/[^0-9\.]/', '', $_POST['S2NC3']);
$S2NC4 = preg_replace('/[^0-9\.]/', '', $_POST['S2NC4']);
}
$con = mysql_connect("localhost","root","............");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("productspec", $con);
$query = mysql_query("UPDATE product SET S1TS1 = ".$S1TS1. " AND SET S1TS2 = ".$S1TS2);
mysql_close($con);
I have only tried to update the first two values in the table to see if it would work.
Could anyone help please?
Thanks
Last edited: