Jump to content

Read Messages


RTS

Recommended Posts

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:
[code]<?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);
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/23679-read-messages/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.