Why register for free on WebRadiance? |
Why register for free on WebRadiance? |
![]() |
Welcome to WebRadiance forums! WebRadiance is a place for discussion and help on a large range of web design and development related topics such as HTML, CSS, ASP & .NET, PHP and SEO. It is provided for free, without ads and is a friendly place for beginners and professionals alike. By joining us today you can take part in our rapidly growing community. Registering enables you to:
|
![]() ![]() |
Jul 30 2008, 10:15 PM
Post
#1
|
|
|
W.R. Corporal Group: Members Posts: 166 Joined: 24-March 08 Member No.: 883 |
This is another kind of newbie question that I hope someone can help with.
The following query works fine. CODE $getDetails = "SELECT * FROM gallery_item LIMIT 0,6"; as does this CODE $getDetails = "SELECT * FROM gallery_item ORDER BY gallery_id DESC"; The idea is to later adapt the script to page through a set of results. I combined the two with this CODE $getDetails = "SELECT * FROM gallery_item ORDER BY gallery_id DESC LIMIT $startRow,$showmax"; where $startRow is dynamically generated and $showmax is derived from a PHP constant CODE define('SHOWMAX', 6); $showmax = SHOWMAX; but this last bit seems redundant so I was wondering how to insert a PHP constant directly into a MySQL query. I tried a few options but none seems to work. This post has been edited by Beavis: Jul 30 2008, 10:39 PM |
|
|
|
Jul 31 2008, 02:26 AM
Post
#2
|
|
![]() W.R. Corporal Group: Members Posts: 52 Joined: 19-July 08 From: Rotterdam, NLD Member No.: 1,069 |
CODE // concatenation $getDetails = "SELECT * FROM gallery_item ORDER BY gallery_id DESC LIMIT ". STARTROW. ",". SHOWMAX; // or sprintf? $getDetails = sprintf( "SELECT * FROM gallery_item ORDER BY gallery_id DESC LIMIT %d, %d", STARTROW, SHOWMAX ); (and many many more should work) -------------------- |
|
|
|
Jul 31 2008, 09:53 AM
Post
#3
|
|
|
Allegedly Legendary Group: Members Posts: 512 Joined: 31-July 06 From: Winder, GA Member No.: 11 |
or prepared statements: http://dev.mysql.com/tech-resources/articl...statements.html
-------------------- |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 3rd December 2008 - 04:48 PM |