Jump to content


Photo

Display records strange problem!


  • Please log in to reply
2 replies to this topic

#1 benji87

benji87
  • Members
  • PipPipPip
  • Advanced Member
  • 136 posts
  • LocationPortsmouth, UK

Posted 27 October 2006 - 02:45 PM

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:

<?
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");

Could someone please correct me where im going wrong because this one is above me! Thanks

#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 27 October 2006 - 02:48 PM

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):

string mysql_result ( resource result, int row [, mixed field] )


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:

$date_posted=mysql_result($result, 0, 'date_posted');


#3 benji87

benji87
  • Members
  • PipPipPip
  • Advanced Member
  • 136 posts
  • LocationPortsmouth, UK

Posted 27 October 2006 - 02:53 PM

Thank you my good friend that worked a treat and i learnt something new cheers!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users