I have a php page which is showing data in a HTML table taken from a MySQL database. Part of the table has a submit button for people to click to like a row. When clicked it runs a form which reloads the page and attempts to process the new inputs. In the example below all the inputs "submit", "timestamp" and "timestamp2" are set after the button is clicked. In the example the query $jpgh1 works and immediately reloads the row with the updated ticks count. If I use $jpgh2 the page reloads but is not updated. I have tried encasing $rt1 and $rt2 in quotes but that doesn't work. The reason I have the $admin bit is because this is being tested on a live system and I don't want the other users to see the testing. Currently the two values for timestamp and timestamp2 are being shown in the fields on the selected row and they match the values which work in $jpgh1.
if(isset($_POST['submit'])) {
If((isset($_POST['timestamp'])) and (isset($_POST['timestamp2']))) {
$rt1 = $_POST['timestamp'];
$rt2 = $_POST['timestamp2'];
$jpgh1 = mysql_query('update topics set ticks=1 where timestamp=1486723327 and timestamp2=1487081058');
$jpgh2 = mysql_query('update topics set ticks=3 where timestamp=$rt1 and timestamp2=$rt2');
}
}
<?php if($_SESSION['username'] == $admin) {
$t1 = $dnn2['timestamp'];
$t2 = $dnn2['timestamp2'];
?>
<form action='' method='POST'>
<input type='text' id='timestamp' name='timestamp' value='<?php echo $t1; ?>'/><br/>
<input type='text' id='timestamp2' name='timestamp2' value='<?php echo $t2; ?>'/><br/>
<input type='submit' name='submit' value='Tick'/></form>
<?php
}
?>
Needless to say after I posted I found the answer.
if(isset($_POST['submit'])){
If((isset($_POST['timestamp'])) and (isset($_POST['timestamp2'])))
{
$rt1 = $_POST['timestamp'];
$rt2 = $_POST['timestamp2'];
$rt3 = "update topics set ticks=1 where timestamp=$rt1 and timestamp2=$rt2";
$jpgh3 = mysql_query($rt3);
}
}