| | |
Why won't work?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2009
Posts: 47
Reputation:
Solved Threads: 0
When i put in this code WHERE to='$username' won't work?
PHP Syntax (Toggle Plain Text)
<?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; ?>
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#3 Oct 23rd, 2009
It should be this way, thats why -
provided your column name is 'to' in the pm table
PHP Syntax (Toggle Plain Text)
<?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; ?>
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
![]() |
Similar Threads
- Need 2 techies for tech-support, work from home (Tech / IT Consultant Job Offers)
- Requesting shadowing work at home job (Software Development Job Offers)
- 3D Engine Developer Needed from India - Work from home (Web Development Job Offers)
Other Threads in the PHP Forum
- Previous Thread: Sorting an multidimensional array
- Next Thread: php mysql and pdo
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax alerts apache api array beginner binary broken cakephp checkbox class cms code convert cron curl database date directory display download dynamic echo email error file files folder form forms function functions google hack href htaccess html htmlspecialchars image include insert integration ip java javascript joomla limit link login loop mail menu methods mlm mod_rewrite multiple mysql network object oop overwrite parse paypal pdf php problem query radio random recursion redirect regex remote script search securephp server sessions sms soap source space sql structure syntax system table tutorial update upload url validation validator variable video web xml youtube





