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
https://forums.phpfreaks.com/topic/25313-display-records-strange-problem/
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.