To easier explain I have a normal table is in MyISAM format with 4 fields, metaTag, metaDesc, pageTitle & pageContent each in there own column, i have placed a form on the back end of the website which has input fields to pass the value to each table row.
A form example which is in its own include;
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"/>
<label>Page Title</label><input type="text" id="meta-data" name="home_title"/>
<span class="example">Example: Company Name LTd, "main Service"..</span>
<label>Home Page Text</label><textarea class="body-text" name="home_text"></textarea><input type="submit" value="Update" id="home-update" name="home_update"/>
</form>
Then from the form it will send to database like so;
if (isset($_POST['home_update']))
{ mysql_select_db("barryjam_cms");
$sql="INSERT INTO cms (pageTitle, pageText) VALUES ('$_POST[home_title]', '$_POST[home_text]')";
if (!mysql_query($sql))
{
$error =('Error: ' . mysql_error());
}
else
$result_home = "updated";
echo "<script>setTimeout(\"location.replace('control_panel.php')\",2000)</script>";
mysql_close();
}
include ('inc/home_form.php');
As i mentioned this is only a simple bit of code, but when i submit say only page title in the form it will add to pageTitle in the database and leave the other column blank, so when the data is output to the page it will only display the most recent field. I want it so if the field is blank it will still use the previous data on the page. An easy solution would be to use multiple tables but at guess i would say that is extremely bad practice.
Please remember i'm a student trying to learn php & Mysql so my terminolgy and knowledge may not be adequate.
If you could point me in the right direction i would be ever so grateful and thankyou for your time.
PS. i have not took any measures as yet to stop sql injections nor formatted the output string to be html compliant, this is just the foundation to my building blocks. If i'm going in the wrong direction can you please let me know also.
Thankyou
paul