hi all i have got a form generated from a mysql database after each record two images are displayed one with an update symbol the other with a delete symbol.
my question is this how do i update a record when i dont know what the new value is when the image is pressed.
i know i need a way of getting the info and the id when the image is pressed i have done this for the delete button i just cant for the update.
all page code is below.
[php]
<?php
//Start session
session_start();
//Check whether the session variable SESS_MEMBER_ID is present or not or to make sure that the user has not got a student membership
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == ''|| ($_SESSION['SESS_MEMBER_TYPE']) == '')) {
header("location: access_denied.php");
exit();
}
//Check whether the session variable SESS_MEMBER_ID is present or not or to make sure that the user has not got a student membership
if($_SESSION['SESS_MEMBER_TYPE'] == 'user'){
header("location: access_denied.php");
exit();
}
//Include database connection details
require_once('config.php');
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER ,DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
$content ="";
// query to get all records
$qry = mysql_query("SELECT * FROM Message order by messageID DESC");
while($row = mysql_fetch_array($qry)){
$content .="
".$row['timeDate']." |
".$row['blogMessage']." |
![update]() |
![update]() |
";
}
?>
Darren's Blog Spot
<?php
// display alerts for errors
if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {
echo '';
foreach($_SESSION['ERRMSG_ARR'] as $msg) {
echo '',$msg,'
';
}
echo '';
unset($_SESSION['ERRMSG_ARR']);
}
?>
Date of Post |
Post Content |
Update |
Remove |
<?php echo $content;?>
copyright © 2012 Darren's Blog Spot
[/php]