Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 23rd, 2005, 10:56 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: London, London, United Kingdom.
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't get my head around - help.

I have "master" the concept of PHP within html but I can't get my head around SQL queries...

I'm trying to do something pretty simple. I have a table which contain some data (1 line at the moment). the 1st column contain Article_ID. What I want is the highest number of the column.

This is the Query I'm sending:

$query = "SELECT MAX(Article_ID) FROM Table_Article";
$result = mysql_query($query) or die ("Problem encounter ".mysql_error());

$row=mysql_fetch_array($result,MYSQL_NUM);
echo $row['Article_ID'];


I'm officialy not getting this at all since I'm not getting any value.
Can someone correct my code and perhaps inlight me a tiny bit on what I'm thinking wrong?

Thanks.
Reply With Quote
  #2 (permalink)  
Old February 23rd, 2005, 11:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

give the MAX(Article_ID) column a name, like this
$query = "SELECT MAX(Article_ID) AS Biggest_ID FROM Table_Article";

then you show it by using
echo $row['Biggest_ID'];
Reply With Quote
  #3 (permalink)  
Old February 23rd, 2005, 11:19 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: London, London, United Kingdom.
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's finaly working Thanks :)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
I am finding the book a bit over my head pinball2k BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 2 November 30th, 2008 01:40 PM
Compile Confusion with Head Contusion nickLogan BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 8 May 4th, 2007 12:48 AM
For graphics gurus... your head in C++ programmed C++ Programming 1 November 2nd, 2006 07:21 AM
Exception handling hurts my head rodmcleay C# 3 September 21st, 2005 03:27 AM
I am so in over my head AnnMarie Dreamweaver (all versions) 1 May 19th, 2005 02:19 PM



All times are GMT -4. The time now is 06:55 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.