Jump to content

Display records strange problem!


benji87

Recommended Posts

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
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.