Re: getting rows by an ID field or by another field in a table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux