|
|
 |
Re: FN-FORUM: PHP/MySQL Question...
date posted 7th February 2008 21:14
----- Original Message -----
From: "Lists - ARKAD Solutions" [EMAIL REMOVED]
To: [EMAIL REMOVED]
Sent: Thursday, February 07, 2008 10:16 PM
Subject: FN-FORUM: PHP/MySQL Question...
>
> Evening all...
>
> Can someone point me in the right direction for this...
>
> 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.
>
> The code is below.....
>
> TIA
>
> Darren
>
>
>
>
>
> $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";
> }
>
>
Have a look at
http://www.w3schools.com/php/func_mysql_result.asp
$description = mysql_result($result, $i, 0); is getting the the first field
in each row.
$description = mysql_result($result, $i, 1); will get the second field etc
Pam
|
 |
|