Jump to content

Mysql Query


Far Cry

Recommended Posts

Hi there, I am executing this query in the code below, it executes as I want it except when it gets the title, it doesnt get the title for that row it just gets it from the first row in the table... if that makes sense... what is going on?

 

<?php
require'styles/top.php';
?>
<br>

<center><table border='0' width='100%' style='text-align:center; font-weight:bold;'>
<tr>
<td width='33%'>Subject</td>
<td width='33%'>From</td>
<td width='33%'>Date</td>
</tr>
</table></center>
<br>
<?php
		  $query = mysql_query("SELECT * FROM messages WHERE to_user='$username' ORDER BY message_id DESC") or trigger_error('Error: ' . 

mysql_error()); 
$numrows = mysql_num_rows($query);
		if ($numrows > 0){

			while ($row = mysql_fetch_assoc($query)){
				$id = $row['message_id'];
				$from = $row['from_user'];
				$to = $row['to_user'];
				$title - $row['message_title'];
				$content = nl2br($row['message_content']);
                    $date = $row['date'];
				echo"<center><table border='0' width='100%' style='text-align:center; font-weight:bold;'>
<tr>
<td width='33%'>$title</td>
<td width='33%'>$from</td>
<td width='33%'>$date</td>
</tr>
</table></center>
<br>";



			}
	}
	else
		echo '';

	?>
	</div>




	<div id='left'>

	</div>

	<div id='right'>

	</div>

 

 

Link to comment
https://forums.phpfreaks.com/topic/219545-mysql-query/
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.