Jump to content


Photo

Read Messages


  • Please log in to reply
1 reply to this topic

#1 RTS

RTS
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 11 October 2006 - 04:13 PM

I have a page that retrieves four colums ('ID', 'Sender', 'date', 'subject') I need to have it so that when you click the a link to a page called read.php, it gets the mesage ID from the database where the ID equals the message you clicked next to. here is what I have so far:
messages.php:
<?php
$user = $_SESSION['username'];
$con = mysql_connect("localhost","ZackBabtkis","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("test", $con);
$result = mysql_query("SELECT * FROM messages WHERE username = '$user'");
echo "<table border='1' width=728>
<tr>
<th>ID:</th>
<th>From:</th>
<th>On:</th>
<th>Subject:</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr><td width=200>";
  echo $row['ID'];
  echo "</td><td>";
  echo $row['Sender'];
  echo "</td><td>";
  echo $row['Date'];
  echo "</td><td>";
  echo '<a href=read.php>';
  echo $row['Subject'];
  echo '</a>';
  echo "</td><td>";

  }
echo "</table>";

mysql_close($con);
?>


#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 11 October 2006 - 04:16 PM

echo '<a href="read.php?id='.$row['ID'].'">';

then on read.php, you would run a query soemthing like....

$sql = "SELECT * FROM tbl WHERE ID=".$_GET['id'];





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users