Link to home
Start Free TrialLog in
Avatar of ticallian
ticallian

asked on

PHP: Convert 2 Field Recordset to an Array

Using PHP MySQL

I'm looking to convert a 2 field recordset into an array.

The recordset simply contains RecordID, RecordName with around 50 records.

I want to create an array with IDs and Names from the recordset so they link to the records name, like this...

$Array[RecordID] = RecordName

I then want to list a set of values on my page that link the value from a url parameter to the array.

echo $Array[ $URL_Value01 ]
echo $Array[ $URL_Value02 ]
echo $Array[ $URL_Value03 ]
etc...

The code i'm currently using doesn't quite work.

do {
$NewArray = array();
$NewArray = array($row_rs['rs_field_ID'], $row_rs['rs_field_name']);
echo $NewArray[$URL_Param01]." <br/>";
echo $NewArray[$URL_Param02]." <br/>";
echo $NewArray[$URL_Param03]." <br/>";
} while ($row_rs = mysql_fetch_array($rs));

Only URL values of 0 or 1 return a result value - either a complete list of RecordID's or RecordName's.

Thanks for any help.

ASKER CERTIFIED SOLUTION
Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ticallian
ticallian

ASKER

Thank you very much! That done the trick perfectly.

Basically i've created a search facility for a site, the URL parameters are used by a different recordset to filter the actual results.

The array above is linked to a seperate recordset i've created just to add some user-friendly options to manipulate the search results.

Cheers!