mysql & php - building a form select from a database

by "N. Whittley" <nwhittley(at)cinci.rr.com>

 Date:  Sun, 8 Dec 2002 18:14:29 -0500
 To:  <hwg-languages(at)hwg.org>
  todo: View Thread, Original
I am really struggling with a form I am trying to create.  I am creating a
form, that pulls
its options from a database.  I have managed to get three items on the page
to list
but the fourth line is giving me trouble.

My php skills are limited, so obviously there is something here I am not
seeing.
The first case example works perfect.  The next for Hard Drives, doesn't
work at all
and nothing under it will come up either.

// MySQL Database Connection
$connect = @mysql_connect($sql_host, $sql_user, $sql_pass) or
die("Dying...");
$db = @mysql_select_db($sql_db, $connect) or die("Can't Connect");

// Case
$sql = "select cat, name, desp, price from jcpc_inv where cat =\"Cases:ATX\"
order by cat";
$res = @mysql_query($sql, $connect) or die("Can't Query");
$case .= "<select name=\"custom1\" size=\"1\"><option></option>";
while($row = mysql_fetch_array($res)){
$cat = $row['cat'];
$desp = $row['desp'];
$price = $row['price'];
$case .= "<option>$desp +\$$price</option>";}
$case .= "</select>";

That works great... it is when I try to pull in the Hard Drives that I have
a problem.

// Hard Drives
$sql = "select cat, name, desp, price from jcpc_inv where cat =\"Hard
Drives:IDE\" order by cat";
$res = @mysql_query($sql, $connect) or die("Can't Query");
$drive .= "<select name=\"custom4\" size=\"1\"><option></option>";
while($row = mysql_fetch_array($res)){
$cat = $row['cat'];
$desp = $row['desp'];
$price = $row['price'];
$drive .= "<option>$desp +\$$price</option>";}
$drive .= "</select>";

This just does nothing..  I think it has to do with the space between the
word Hard Drives, but I am not sure.
That is how it is set up in the Database.. and this database is imported
from QuickBooks.

Got any suggestions on how I can get this one to work?

Nancy

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA