Hi,
I am trying to insert one record of data into a column, then be able to update it via a form, and then display the current updated record each time the page is loaded in a text field - so the user can update it again.
This is what I have:
$sql = "INSERT INTO website_settings (website_name) VALUES('$website_name')";
mysql_query($sql);
$update = mysql_query("UPDATE website_settings SET website_name = '$website_name'");
mysql_query($update);
$result = mysql_query("select * from website_settings");
$row = mysql_fetch_array($result);
It currently inserts and updates, but it is inserting multiple records and updating all of them to the same value. I cannot get it to only insert one record and only update one record.
Also, I cannot get the value to stay in the text field each time the page is re-visited.
This is my form:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input name="website_name" value="<?php echo $row['website_name']; ?>" type="text" class="input" />
<input type="submit" name="Submit" value="Submit" />
</form>
Any suggestions to what I have wrong?
Thanks!