RE: [PHP-DB] Need Help with returning new id's
| From: | Gurhan Ozen | Date: | Tue, 19 Mar 2002 21:50:08 +0000 |
| Subject: | RE: [PHP-DB] Need Help with returning new id's | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17768@lists.php.net to get a copy of this message | ||
Hi,
Did you copy and paste your code?IF yes, I have noticed a problem on the
code you posted.. Y
The line:
$run_query = ($maxid,$db_connect);
will fail as you didn't put the function name in. Rewrite it as:
$run_query = mysql_query($maxid,$db_connect);
Gurhan
-----Original Message-----
From: Jason McCormack [mailto:mccormack_j@hotmail.com]
Sent: Tuesday, March 19, 2002 1:31 AM
To: php-db@lists.php.net
Subject: [PHP-DB] Need Help with returning new id's
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
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php