<?php
include("include/session.php");
?>
<?php
$db = new PDO('mysql:host=localhost;dbname=******x2_login', '******x2_login', '********');
$stmt = $db->query('SELECT value FROM settings WHERE value = "Login Script" ');
$id = $stmt->fetchColumn(0);
if ($id !== false) {
echo $id;
} ?>
<?php
if(isset($_POST['Submit'])){//if the submit button is clicked
$update = "UPDATE settings WHERE value = 'Login Script' SET value = '$value' ";
$db->query($update) or die("Cannot update");//update or error
}
?>
<html>
<form action="" method="post">
<table border="0" cellspacing="10">
<tr>
<td>Name:</td> <td><input type="text" name="value" size="100" value=""></td>
</tr>
<tr>
<td><INPUT TYPE="Submit" VALUE="Update the Record" NAME="Submit"></td>
</tr>
</table>
</form>
</html>
<?php
if($update){//if the update worked
echo "<b>Update successful!</b>";
}
?>
Hi, I'm trying to update a row of a databse, a certain record. When I click submit, I get cannot update (as it says in the script.) The top part (php) gets the value of the record, please could someone tell me how to display the actual value of the row, so when it changes it displays the changed record.
In the databse I have two colums, name and value, I have 1 row, in the column 'name' I have SITE_NAME and the column next to it 'value', in the row I have: 'Login Script'. I don't know how to make it so that it displays whatever the text is in the row. It's the first row.
I also can't get it to update the record when 'Submit' is pressed
I'm an amateur at PHP and MySQL so please could someone help, I would really appreciate it. Thank You.