[thelist] Doh! question for MySQL

Adrian Fischer adrian at logo-logic.com
Wed Feb 14 04:05:17 CST 2001

I might be able to help...

$db = &dbconnect;
 $dbh=$db->prepare("SELECT COUNT(*) FROM tblDockets WHERE docPending<=0 AND
docClosed<=2 AND docAccountEnd >= " . int($current_time) . " ");
($count) = $dbh->fetchrow_array();
$db_query = "SELECT
docBusName,docStreet,docBusPhone,docState,docRegion,docSuburb FROM
tblDockets WHERE docPending<=0 and docClosed<=2 ORDER BY docId LIMIT $show,
$db = &dbconnect;
$varReturnResult = $dbh->execute();
if ($varReturnResult)
while ($varDBInfo = $dbh->fetchrow_arrayref) {
if ($a<=$limit){
if ($i % 2 == 1) {
$config{'colortablebody'}=$config{'odd_row_color'}; }
else { $config{'colortablebody'}=$config{'even_row_color'}; }
print "<TR
br>Phone: $$varDBInfo[2]<br>$$varDBInfo[5] $$varDBInfo[4]

try this on for size....not sure how technically correct it is but it uses
count then deducts the number you want to display and then uses LIMIT to
display the last x number of records (in my case 5)  just change the 5 to a
10 and wam bam thank you mam......you have it done.

I look forward to someone who actually knows what there talking about
pointing out a more efficient way......hey , what can I say...I roll my
own....it aint pretty but it works...


Adrian Fischer

> The client wants to show on the front page the last ten items that were
> So I was thinking that I would write a query to pull the latest ten - but
> don't want to do it on a timestamp, in case nothing gets sold in
> thanks for your help
> -w

More information about the thelist mailing list