RTS Posted October 11, 2006 Share Posted October 11, 2006 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 More sharing options...
trq Posted October 11, 2006 Share Posted October 11, 2006 [code=php:0]echo '<a href="read.php?id='.$row['ID'].'">';[/code]then on read.php, you would run a query soemthing like....[code=php:0]$sql = "SELECT * FROM tbl WHERE ID=".$_GET['id'];[/code] Link to comment https://forums.phpfreaks.com/topic/23679-read-messages/#findComment-107473 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.