View Single Post
Old 08-19-2009, 12:08 PM   #4 (permalink)
jasonberresford
The Wanderer
 
Join Date: Aug 2009
Posts: 11
Thanks: 1
jasonberresford is on a distinguished road
Default

Here's my quick edit:



Code:
<?php
//Connect to database
include ('connect1.php');
$pageid = $_GET['id'];
$queryget = mysql_query("SELECT* FROM comments WHERE pageid = '$pageid'");
while ($row = mysql_fetch_assoc($queryget))
{
//get row data and store in var's
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$message = $row['message'];
$date = $row['date'];
$time = $row['time'];
 
 //show data to user
echo"<table><tr><td>
Posted by: <b>$name ($email) on $date</b>
</td></tr><tr>

<td>".strip_tags($message)."</td></tr></table>";
}

echo "<hr>";

if ($_POST['submit'])
{

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$date = date ("m-d-Y");
$time = date ("H:i:s");

if($name&&$message)
{
$querypost = mysql_query ("INSERT INTO comments VALUES ('','$name','$email','$message','$date','$time','$pageid')");
echo"Please wait..... <meta http-equiv='refresh' content='1;url=results3.php?id=$id'>";
}
else
echo "Please fill out all fields.";
}

echo "<form action='results3.php?id=$id' method='POST'><table width='100%'>
<tr><td width='5%' valign='top'>Name:</td>
<td><input type='text' name='name' maxlength='25'></td></tr>

<tr><td valign='top'>Email:</td><td><input type='text' name='name' maxlength='25'></td></tr>

<tr><td valign='top'>Message:</td><td>
<textarea cols='20' rows='2' name='message' maxlength='250'></textarea>
<p>
<input type='submit' name='submit' value='Post'>
</td>
</tr>
</table>
</form>";
?>
Something like that .. Grab the id at the start, when you do an insert insert with the ID, and when you do the select for the page grab the ID .. nothing to it :)
jasonberresford is offline  
Reply With Quote
The Following User Says Thank You to jasonberresford For This Useful Post:
tearsofthesun (08-19-2009)