Interesting Query
Posted: Thu May 22, 2003 12:15 am
I am trying to create a PDF type of navigation using PHP and MySQL.
Everything is going fine, but I thought I see if there is a way to do part of this more elegantly.
This would be the part were I get the table ID to use in my display query condition. Here's what I need:
The total count of my recordset
The starting ID value
The last ID value
Right now to make it work I do this:
My instincts tell me that this is very cludgy and there is a much nicer way to do this.
I feel like I'm having brain block, I need a kick!
Thanks!
- D
Everything is going fine, but I thought I see if there is a way to do part of this more elegantly.
This would be the part were I get the table ID to use in my display query condition. Here's what I need:
The total count of my recordset
The starting ID value
The last ID value
Right now to make it work I do this:
Code: Select all
// get the first ID field
// get total row count
$sql = "SELECT dealership_id FROM dealerships ORDER BY dealership_id ASC";
$result1 = mysql_query($sql, $dblink) or die(mysql_error() . "<br><b>Query:</b> $sql");
// PAGE COUNTER /////////////////////////////
$total = mysql_num_rows($result1); // total fields
while($t_rows = mysql_fetch_assoc($result1))
{
// the starting ID value
$starting_id = $t_rowsї'dealership_id'];
break;
}
$sql = "SELECT dealership_id FROM dealerships ORDER BY dealership_id DESC";
$result2 = mysql_query($sql, $dblink) or die(mysql_error() . "<br><b>Query:</b> $sql");
while($t_rows = mysql_fetch_assoc($result2))
{
// the starting ID value
$ending_id = $t_rowsї'dealership_id'];
break;
}I feel like I'm having brain block, I need a kick!
Thanks!
- D