RE: FN-FORUM: PHP/MySQL Question...
date posted 7th February 2008 21:10
> -----Original Message-----
>
> I'm trying to get several fields out of a database record, the
> fields are as
> follow:
>
> NewsDate
> NewsHeadline
> NewsText
> NewsFile
>
> The only field that is coming out at the moment is the first
> field which is
> NewsID.
>
> $rows_per_page = 4;
> $db = 'NBPA';
> $sql = "SELECT * FROM News";
> $result = mysql_query($sql);
> $total_records = mysql_num_rows($result);
> $pages = ceil($total_records / $rows_per_page);
> mysql_free_result($result);
>
> if (!isset($screen))
>
> $screen = 0;
> $start = $screen * $rows_per_page;
> $sql = "SELECT * FROM News ORDER BY NewsDate ";
> $sql .= "LIMIT $start, $rows_per_page";
> $result = mysql_query($sql);
> $rows = mysql_num_rows($result);
> for ($i = 0; $i < $rows; $i++)
> {
> $description = mysql_result($result, $i, 0);
>
> echo "\$description = $description\n";
> }
>
>
Try this:
$description = mysql_result($result, $i, 0);
$field2 = mysql_result($result, $i, 1);
$field3 = mysql_result($result, $i, 2);
etc.
i.e. the 3rd parameter is an index to the columns in your result set. The
1st field is 0 (zero).
Nick