0

When i put in this code WHERE to='$username' won't work?

<?php
$connect = mysql_connect ("localhost","root","") or die (mysql_error());
mysql_select_db ("login4") or die (mysql_error());
session_start();
$_SESSION['username'];
$username = $_SESSION['username'];
$query = mysql_query("SELECT * FROM pm ORDER BY id DESC");
$message = '' ;
while ($row = mysql_fetch_array($query)){
$id = $row['id'];
$to = $row['to'];
$from = $row['from'];
$title = $row['title'];
$date = $row['date'];
$message .= "<tr><td><a href='viewpm.php?&id=".$id."'>".$title."</a><br /></td><td>".$date."<br /></td></tr>";
}
?>
<table width="100%">
<tr><td>Title</td><td>Date</td></tr>
<?php
print $message;
?>
4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by web3
0

It should be this way, thats why -

<?php
$connect = mysql_connect ("localhost","root","") or die (mysql_error());
mysql_select_db ("login4") or die (mysql_error());
session_start();
$_SESSION['username'];
$username = $_SESSION['username'];
$query = mysql_query("SELECT * FROM pm where to='".$username."' ORDER BY id DESC");
$message = '' ;
while ($row = mysql_fetch_array($query)){
$id = $row['id'];
$to = $row['to'];
$from = $row['from'];
$title = $row['title'];
$date = $row['date'];
$message .= "<tr><td><a href='viewpm.php?&id=".$id."'>".$title."</a><br /></td><td>".$date."<br /></td></tr>";
}
?>
<table width="100%">
<tr><td>Title</td><td>Date</td></tr>
<?php
print $message;
?>

provided your column name is 'to' in the pm table

0

@macneato
i can print array without where to='".$username."'
@network18
code didn't work

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.