benji87 Posted October 27, 2006 Share Posted October 27, 2006 Hi all im trying to display some records from my database using $_GET id as the unique variable. Trouble is it seems to display the id on all of my variables. It will only work if i choose to select a certain field from the database. Here is the problem code:[code]<?include 'includes/db.php';$query=("SELECT * FROM ssrfc_noticeboard WHERE id = '{$_GET['id']}'");$result=mysql_query($query);$date_posted=mysql_result($result,"date_posted");$title=mysql_result($result,"title");$message=mysql_result($result,"message");[/code]Could someone please correct me where im going wrong because this one is above me! Thanks Quote Link to comment Share on other sites More sharing options...
akitchin Posted October 27, 2006 Share Posted October 27, 2006 the manual should be the first place to look when something seems to be going wrong with a function, rather than your code's logic itself (or query errors):[quote]string mysql_result ( resource result, int row [, mixed field] )[/quote]you've got to specify the row before the fieldname. here, since you're only grabbing one row (or should only be), you'd specify 0 as rows start counting from 0:[code]$date_posted=mysql_result($result, 0, 'date_posted');[/code] Quote Link to comment Share on other sites More sharing options...
benji87 Posted October 27, 2006 Author Share Posted October 27, 2006 Thank you my good friend that worked a treat and i learnt something new cheers! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.