PDA

View Full Version : Query String: How to append the ID of a row of a newly inserted database row (PHP)?


Austintxous
10-31-2011, 09:04 PM
OK, I can get the number of the last row created, as I do below. Now, I want to append it to the URL? query string so I can use this particular record on the next page. Here's the way I'm trying to do it, where the field iduserid is my primary key. If I just insert it into a text field on the page it displays the correct number. ( note: LastRec is a record set that contains the iduserid field of the current row)

But it doesn't return anything in the query string. What's wrong?
<?php
$result = mysql_query('SELECT iduserid FROM userinfo ORDER BY iduserid DESC LIMIT 1');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
$USER_ID = mysql_fetch_field($result,0);
?>

<a href="cp-AccountInfo.php?<?php echo $_SERVER['QUERY_STRING']?>"iduserid="<?php echo $USER_ID ?>""><div class="OKbtn"></div></a>