• Help
  • Search
  • Login
  • Register
  • Home

Forum: web design and graphics community

Celestial Star Forum > Web Development > Coding > Max function with a Mysql row?
Pages: [1]
« previous next »
  Print  
Author Topic: Max function with a Mysql row?  (Read 495 times)
Alis
Angeling
*
Posts: 9



View Profile WWW
Max function with a Mysql row?
« on: January 13, 2008, 07:17:39 PM »

Hello! Lot of time have passed since my last visit. I need help with a php coding.
I've to do an IF function and I've to keep the highest number from the $id column in my Mysql table.

I've tried this code:

Code:
<?php
$_GET
['$id'];
if (
$id = max(array ($id)))


but it seems it doesn't work. I need that where the $id is the max number ( so the last row added to the table) it does a certain thing.
Can you help me? I don't know where I'm wrong!
Logged

y soul is painted like wings of butterflies
Alis
Angeling
*
Posts: 9



View Profile WWW
Re: Max function with a Mysql row?
« Reply #1 on: January 15, 2008, 02:17:41 PM »

Since Melfia Reply has been deleted, I just want to tell if anyone can help me with the code.
Logged

y soul is painted like wings of butterflies
Vangs
Administrator
Valkyrie Randgris
*****
Posts: 523



View Profile WWW
Re: Max function with a Mysql row?
« Reply #2 on: January 16, 2008, 06:27:48 AM »

Try this:

Code:
<?php
if(isset($_GET['id']))
{
   
$id = intval($_GET['$id']);
}
else
{
   
$id = '';
}
if (
is_int($id))
{
   
//your coding
}
else
{
   die(
'Invalid input.');
}

It'll first check to see if $_GET['id'] exists, if it doesn't and you reference it in a script you'll get an E_WARNING error. If $_GET['id'] doesn't exist then it will set $id as a blank variable, however if it is set it'll get the interger variable from the string and set the value to $id. It then tests to ensure that $id has an interger value and well proceed with your coding or fail if not.
Logged

Pages: [1]
  Print  
« previous next »
 
Jump to:  

  • Welcome, Guest
  • Members login
  • Register for free

General

  • General
  • New members
  • Announcements
  • Support / Suggestions

Art boards

  • Creative mediums
  • Requests and offers
  • Tutorials
  • Celestial Star tutorials

Web development

  • Coding
  • Web design
  • Advertisements / affiliation

Off-topic

  • The non-sense
  • Ententainment

Go up
eXTReMe Tracker
  • Valid XHTML
  • Valid CSS
Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC | Seo4Smf v0.2 © Webmaster's Talks
Loading...