PHP + MySQL -> Limiting to 1 Result
Posted: Sun Jul 01, 2007 11:41 am
feyd | Please use
Goal/Question: I would like for this to display only the first result the query receives. So far I've searched and tried adding the and functions to the query, but it only nets me a blank white page after that. I have considered the fact that since I do not have a deep knowledge of the application; that merely using one of those functions or a 'LIMIT 1' statement may not be possible, in which case I would have to write and display my own query. I'm hoping this can be resolved through modifying this query. Any information you can lend would be appreciated.
Thanks!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[b][u]Modder Info:[/u][/b] I am currently very, very new to PHP and MySQL. I've administered an application that uses both of these elements plus XHTML for about the past year. The application is a widely used one in the MMORPG world called [url=http://www.eqdkp.com]EQDKP[/url]. Due to recent expressions of desired enhancements, and my personal desire to learn something new, I decided to try and modify first, and develop and enhance second.
[b][u]Info:[/u][/b] I am currently trying to display 1 record, instead of displaying all records inside this application on one of the pages. I have the query here:Code: Select all
$sql = 'SELECT i.item_id, i.item_name, i.item_buyer, i.item_date, i.raid_id, i.item_value, r.raid_name, m.member_class_id, c.class_name AS classr_name, m.member_name
FROM ' . ITEMS_TABLE . ' i, ' . RAIDS_TABLE . ' r, ' . CLASS_TABLE . ' c, ' . MEMBERS_TABLE . ' m
WHERE i.item_buyer = m.member_name
AND m.member_class_id = c.class_id
AND r.raid_id=i.raid_id
AND i.item_name = CONVERT(_utf8 \'Helm of the Vanquished Defender\' USING latin1)
ORDER BY '.$current_order['sql']. '
LIMIT '.$start.','.$user->data['user_ilimit'];Code: Select all
TOP 1Code: Select all
ROWCOUNTThanks!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]