Need Help with returning new id's
| From: | Jason McCormack | Date: | Tue, 19 Mar 2002 06:31:03 +0000 |
| Subject: | Need Help with returning new id's | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17765@lists.php.net to get a copy of this message | ||
Hello All,
I am trying to return the largest id for a table and then print the value to
a page. My query works fine in MySQL, the problem is getting the value to
show in a web page with php. This is what I am trying to process.
TABLEID | VALUE
1 | Test
2 | Test 2
3 | Test 3
In the sample table above I am trying to pull back a value of 3 and print to
a web page via php.
$maxid = "select max(tableid) from table as largestid";
// db_connect is my database connection. I know this works because I have
other pages that return
// results based on my queries without any problems
$run_query = ($maxid,$db_connect);
This is were I get a bit lost. I have tried using all sorts of various mysql
functions without success
$row = mysql_fetch_row($run_query);
$mymaxidvalue = $row[0];
echo $mymaxidvalue;
As I stated above I have tried many different ways to get the desired
results but have been unsuccessful. Any help would be greatly appreciated.
Thanks,
Jason