Hi Thanks for your reply.
I have been trying to get the script working and am not quite there. I can get the rows to display and can get the one i want to amend to display when you select a radio button, but i cant get the changes to actually save to the database table.
The amended php is as follows, but I am sure it is me that is wrong and not your code, just not sure what to do now.
table is called entries, the 4 fields are called id, date, title and entry and i only need the title and entry to display.
<link href="styles.css" rel="stylesheet" type="text/css" />
<?php
// This is to connect to and open the database
include 'library/config.php';
include 'library/opendb.php';
//$query = mysql_query("SELECT id, date, title, entry, FROM entries"); //query to select all rows that may be editable
$query = mysql_query("SELECT id, date, title, entry, DATE_FORMAT(date,'%D %M %Y') as date FROM entries ORDER by date DESC");
$numrows = mysql_num_rows($query);
if(empty($numrows)) {
//what to do if there are no rows
}else{
echo "<form name='edit' method='post'>"; // echo out a new form
echo "<input type='submit' name='editsubmit' value='Edit Selected'>"; // and an edit selection button
while($editarray = mysql_fetch_array($query)) { // and create the array from the query
echo "<input type='radio' name='editradio[]' value='".$editarray[id]."'>"; // create the radio selection so that the user can select a record to edit
echo $editarray[title];
echo $editarray[entry]; // the information you want displayed.. you can put html around it to make it look nice
}
echo "</form>"; // end the form
$editid = $_POST['editradio']; // set the editid variable
if($_POST['editsubmit']) { // on pressing Edit Selection
foreach($_POST['editradio'] as $evalue) { // foreach (using radios only return one) selected record as evalue
$editquery2 = mysql_query("SELECT * FROM entries WHERE id='".$evalue."'"); // select the respective row using id = $evalue
$numrows = mysql_num_rows($editquery2); //check to make sure it hasnt messed up horribly
if(empty($numrows)) {
echo "error. wrong id. hope this doesnt happen"; // bad thing shouldnt happen
}else{
while($editarray2 = mysql_fetch_array($editquery2)) {
echo "<form name='editnews2' method='post'>"; // start a new form for the actual editing form
echo "<input type='submit' name='edit2submit' value='Update'>"; // echo out your update button
echo "<input type='text' name='editfield1' value='".$editarray2['title']."' />";
echo "<input type='text' name='editfield2' value='".$editarray2['entry']."' />"; // the fields that are editable
echo "</form>"; // ending this one also
if($_POST['edit2submit']) { //only if you post the Update button
$newfield1 = $_POST['editfield1']; //set some new variables
$newfield2 = $_POST['editfield2'];
$editquery3 = mysql_query("UPDATE entries SET title = '".$newfield1."', entry = '".$newfield2."' WHERE id = '".$evalue."'") or die(mysql_error()); // do your update query with the new variables where the id = $evalue (part of array, but again, will only be 1 value anyways since this example uses radio buttons)
}
}
}
}
}
} // there you go hope it helps
// This is to close database
mysql_close($conn);
?>
I hope you can decipher what i ahve done and put me on the road to success
Thanks again