Here is an example of my code, ignore the format of the echo line at the bottom I was just testing that it displayed what I was looking for.
So just for clarity, I already have the site in html ( http://www.mortgagehell.co.uk) but I want to use php to automate it more and so far its going well!
In this script what I want to acheive is to list all of the ID and heading field results in a drop down list, the user then selects which article it is they want to modify and I then pass the ID number to another script I have already prepared which will display the article from the database and allow it to be amended then saved back to the database.
I am confident on all aspects apart from being able to display the results of the ID and header in a drop down box and to allow the user to select a particular article for editing. I dont suppose the ID has to actually be displayed, it could be in a hidden field?
I think I am going along the right track?
Here is the sample code I prepared.
PHP Code:
<?
// Connecting
$connect = @mysql_connect('localhost', 'root', 'martin');
if (!$connect) {
die( '<p>problem ' . mysql_error() . '</p>');
}
// Select Database
$select = @mysql_select_db('mortgage');
if (!$select) {
die( '<p>problem ' . mysql_error() . '</p>');
}
// Get data from tables
$res = @mysql_query("SELECT * FROM news");
while ( $row = mysql_fetch_array($res) ) {
echo ('<p>' . $row['ID'] . $row['heading'] . $row['article'] . $row['author'] .$row['source'] .$row['articledate'] . '</p>');
}
?>
|