Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 23rd, 2005, 11:56 AM
Friend of Wrox
Join Date: Dec 2004
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());

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?

Old February 23rd, 2005, 12:04 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

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'];
Old February 23rd, 2005, 12:19 PM
Friend of Wrox
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts

It's finaly working Thanks :)

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 02: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 08: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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.