Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Different id values between web access and database access

Status
Not open for further replies.

jisoo22

Programmer
Joined
Apr 30, 2001
Messages
277
Location
US
Hello all,

I'm using postgresql and PHP to set up a small website. I have a slight problem that I have been unable to explain. Basically the part that I'm trying to do is call up the maximum value in my primary serial key field in my database and post it on a webpage. But when I do that, the number is wrong...whereas the highest number record in my table field is 134, the webpage prints out "6" during testing. These are the statements I'm using:

$default_query = "SELECT t0.* FROM $table_name t0";
$max_query = "SELECT max(num_id) FROM $table_name";
$query = pg_Exec($conn, $default_query);
$maxid = pg_Exec($conn, $max_query);
$num_id = pg_Result($query, $maxid, num_id);
echo"$num_id";

Any ideas are appreciated!

Thanks,
Jisoo22
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top