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
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
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
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:
Please select a destination:
-----------------------------
General
-----------------------------
=> General
=> New Members
=> Announcements
=> Support / Suggestions
-----------------------------
Contests
-----------------------------
=> Archive
===> Contests
===> Blend Challenges
===> SOTW
-----------------------------
Art Boards
-----------------------------
=> Creative mediums
=> Requests & offers
=> Tutorials
===> Celestial Star Tutorials
-----------------------------
Web Development
-----------------------------
=> Coding
=> Web Design
=> Advertisements / Affiliation
-----------------------------
Off-topic
-----------------------------
=> Entertainment
-----------------------------
Español (Spanish Only)
-----------------------------
=> General / Bienvenida
=> Anuncios / Ayuda
=> Código / Desarrollo web
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
Loading...