Liz_W
05-18-2005, 12:53 AM
I am trying to write a query that takes input from a web form and selects the applicable information from a database and then outputs the results in html.
The database is called car, there are five columns, in this order;
--------------------------------------------------------------------------
registration
make
model
colour
ratecode
--------------------------------------------------------------------------
What I want to do is display the colour and registration of the cars that match the selected make and model from a drop down list.
I tried a go at it but ended up in a mess as you see, can someone help me please.
if (!($dbh = DBI->connect("DBI:mysql:databasename:localhost", 'username', 'password')))
{
&outputErr("couldn't connect to database".DBI->errstr);
}
if (!($query = $dbh->prepare("SELECT * FROM car Where 'make' And 'model' =='$type'")))
{
&outputErr("couldn't prepare statement".$dbh->errstr);
}
#execute the query
if (!($query->execute()))
{
&outputErr("couldn't execute statement".$query->errstr);
}
while (@car = $query->fetchrow_array())
{
$key=$car[0];
$value=$car[1];
}
$query->finish;
The database is called car, there are five columns, in this order;
--------------------------------------------------------------------------
registration
make
model
colour
ratecode
--------------------------------------------------------------------------
What I want to do is display the colour and registration of the cars that match the selected make and model from a drop down list.
I tried a go at it but ended up in a mess as you see, can someone help me please.
if (!($dbh = DBI->connect("DBI:mysql:databasename:localhost", 'username', 'password')))
{
&outputErr("couldn't connect to database".DBI->errstr);
}
if (!($query = $dbh->prepare("SELECT * FROM car Where 'make' And 'model' =='$type'")))
{
&outputErr("couldn't prepare statement".$dbh->errstr);
}
#execute the query
if (!($query->execute()))
{
&outputErr("couldn't execute statement".$query->errstr);
}
while (@car = $query->fetchrow_array())
{
$key=$car[0];
$value=$car[1];
}
$query->finish;