Forgive me for the long post.

I have a script that pulls information from a table. This table contains foreign id keys for other tables. This code works just fine, but pulls id numbers. I would like to make a change to this file to convert the id numbers into their matching names. I have tried to use this type of code:

// create connection
$connection = mysql_connect(localhost, nwpuser, nwp384fuel3)
or die("Couldn't make connection.");

// select database
$db = mysql_select_db("NWP", $connection)
or die("Couldn't select database.");


// create SQL statement

$sql = "SELECT NAME

FROM DELIVERY

WHERE ID= '$F_DELIVERY_ID'";

// execute SQL query and get result
$sql_result = mysql_query($sql,$connection)
or die("Couldn't execute query.");

// put data into drop-down list box
while ($row = mysql_fetch_array($sql_result)) {

$delivery_name = $row["NAME"];


within the file below to convert the id #s into names, but I get errors. Any help would be greatly appreciated!


The file:

<?

/create connection

$connection = mysql_connect (localhost, ####, ###) or die ("Couldn't connect to server.");


// select database


$db = mysql_select_db (DB, $connection) or die ("Couldn't select database.");


// create SQL statement


$sql = "SELECT ID, CREATED, F_LOCATION_ID, F_CUSTOMER_ID, F_FUEL_TYPE_ID, F_DELIVERY_ID, VOLUME, PRICE
FROM BID
WHERE REVIEWED = 0";

// execute SQL query and get result

$sql_result = mysql_query($sql,$connection) or die ("Couldn't execute query.");


//start results formatting

echo "<br><br><div align=center>";

echo "<table border=0 cellpadding=3 cellspacing=3 width='90%'>";

echo "<tr><td colspan=9><font face='verdana,arial,helvetica' size='+1' color='#000000'><b>New Bids</b></font></td></tr>";


// format results by row


while ($row = mysql_fetch_array($sql_result)) {


$CREATED = $row["CREATED"];
$ID = $row["ID"];
$F_CUSTOMER_ID = $row["F_CUSTOMER_ID"];
$F_LOCATION_ID = $row["F_LOCATION_ID"];
$F_FUEL_TYPE_ID = $row["F_FUEL_TYPE_ID"];
$F_DELIVERY_ID = $row["F_DELIVERY_ID"];
$VOLUME= $row["VOLUME"];
$PRICE = $row["PRICE"];
$REVIEWED = $row["REVIEWED"];
$ACCEPTED = $row["ACCEPTED"];
$COMMENTS = $row["COMMENTS"];

echo "<tr bgcolor='#999999'>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'><b>Date:</b></font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'><b> Bid Number:</b></font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'><b>Customer:</b></font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'><b>Location:</b></font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'><b>Fuel Type:</b></font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'><b>Delivery Type:</b></font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'><b>Volume:</b></font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'><b>Price:</b></font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'><b>Accept:</b></font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'><b>Decline:</b></font></td>

</tr>";


echo "<tr>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'>$CREATED</font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'>$ID</font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'>$F_CUSTOMER_ID, $customer_name</font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'>$F_LOCATION_ID</font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'>$F_FUEL_TYPE_ID</font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'>$F_DELIVERY_ID, $delivery_name</font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'>$VOLUME</font></td>

<td><font face='verdana,arial,helvetica' size='-2' color='#000000'>$PRICE</font></td>


<td>

<form action= method=GET>
<input type=hidden name='ID' size=25 maxlength=25>
<input type=submit value=Accept>
</form>

</td>

<td>

<form action= method=GET>
<input type=hidden name='ID' size=25 maxlength=25>
<input type=submit value=Reject>
</form>

</td>

</tr>";

}


echo "</table>";


echo "</div>";

include("footer.inc");


//free resources and close connection


mysql_free_result($sql_result);
mysql_close($connection);


?>