Multiple mysql columns in dynamic drop down

Hi, i have been working on this for a few days now and cannot resolve what i am trying to achieve.

I have a dynamic drop down box populated from a column in my mysql database which works fine, just that i need more columns to be displayed in the selection list to be passed to in my form.

This is the code from my working single selection.

<? $sql="SELECT partnumber,cost FROM toners"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id1=$row["partnumber"]; $id2=$row["cost"]; $options.="".$id1.''; } ?> Choose <? echo $options?>

i have been trying to manipluate the $options.=" part but just cannot get it to work right.

This is the closest i have got but just not quite there yet !

$options.='<option value="' . $row['partnumber'] . '">' . $row['partnumber'] . ',' . $row['cost'] . '">' . $row['cost'] . '</option>';

I get the drop down but the text is out of place.

The idea is to then post the selected values to my database.

In the end i would like to add more values to the selection list, yes i know this will make it a large but i am trying to make this fool proof for the people using this.

thanks all

paul

Sponsor our Newsletter | Privacy Policy | Terms of Service