Re: getting rows by an ID field or by another field in a table
| From: | Joseph Crawford | Date: | Tue, 06 Dec 2005 19:50:54 +0000 |
| Subject: | Re: getting rows by an ID field or by another field in a table | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40769@lists.php.net to get a copy of this message | ||
i would do something like
SELECT id, date, subject FROM journal LIMIT 20
ofcourse this would mean you have to add an id column to your table and i
would make that a primary key and auto_increment,
this way when you do the select you could do something like this
$res = mysql_query("SELECT id, date, subject FROM journal LIMIT 20");
echo '<table>';
echo '<tr><td>Subject</td><td>Date</td></tr>';
while($entry=mysql_fetch_array($res)) {
echo '<tr><td><a href="details.php
?id='.$entry['id'].'">'.$entry['subject'].'</a></td><td>'.$entry['date'].'</td></tr>';
}
echo '</table>';
--
Joseph Crawford Jr.
Zend Certified Engineer
Codebowl Solutions, Inc.
1-802-671-2021
codebowl@gmail.com