Updating Database Using PHP & MySql
Posted: Mon Jul 30, 2012 10:50 am
Hello,
I am currently trying to make a page where the user can update the content themselves. I have managed to get one of the pages working however the second one is not and for the sake of me I cannot figure out what it is. I have attached the code below. All of the querys seem to be working fine, except the $editwww query. I you notice anything that would help that would be great, cheers.
I am currently trying to make a page where the user can update the content themselves. I have managed to get one of the pages working however the second one is not and for the sake of me I cannot figure out what it is. I have attached the code below. All of the querys seem to be working fine, except the $editwww query. I you notice anything that would help that would be great, cheers.
Code: Select all
<?php
if ($_SESSION['uid'])
{
include 'dbconnect.php';
$now = time();
$a = $_GET['a'];
$wwwuid = $_POST['wwwid'];
$wwwtext = $_POST['wwwtext'];
//$wwwheader = $_POST['wwwheader'];
if ($a == 'edit')
{
$editwww = mysql_query("UPDATE www SET Text = '$wwwtext' WHERE ID = '$wwwuid'");
echo $wwwtext;
}
?>
<table border="1">
<tr>
<th>ID</th>
<th>Text</th>
<th></th>
</tr>
<?php
$wquery = mysql_query ('SELECT * FROM www ORDER BY ID DESC LIMIT 5');
if (!$wquery)
{
die ('<p> Error performing query: ' .mysql_error() . '</p>');
}
while($wwwq = mysql_fetch_array($wquery))
{
$wwwid = $wwwq['ID'];
$wwwtext = $wwwq['Text'];
//$wwwheader = $wwwq ['Header'];
echo ("<tr>\n<td>" . $wwwid . "</td>\n");
?>
<form method="post" action="AED.php?aedp=aedwww1&a=edit">
<input name="wwwid" type="hidden" value="<?php echo $wwwid ?>" />
<td>
<textarea name="wwwtext" cols="50" rows="20"><?php echo $wwwtext ?></textarea>
</td>
<td>
<input name="Submit" type="submit" value="Submit Changes" />
</td>
<?php
}
?>
</form>
</table>
<?php
}
else
{
echo 'Unathorized Access';
}
?>