MySQL Forums
Forum List  »  PHP

Retrieve data using checkboxes php mysql
Posted by: Martha Van Orshoven
Date: June 09, 2010 01:03PM

here is the php code:
// Connect to the database
require_once('connectvars.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, DB_PORT, DB_PATH);
// Error checks
//if no categories are checked - report an error to the user

// New Query to get the results
$query = "SELECT * FROM common_name, main_native WHERE"

// open the parens in the query to start the category OR clause
$query = $query ."( "
if (category[grass].checked) THEN
$query = $query . "( main_native.category = "grass" ) OR"
end if

if (category[tree].checked THEN
$query = $query . "( main_native.category = "tree" ) OR "
end if

if (category[wildflowers & herbs].checked THEN
$query = $query . "( main_native.category = "wildflowers & herbs" ) OR "
end if

if (category[shrubs & vines].checked THEN
$query = $query . "( main_native.category = "shrubs & vines" ) OR "
end if
// we have an extra " OR " at the end of the query that want to remove
//$query = $query - trailing " OR "

// close paren from category OR clause -
// $query = $query . ") "
. ") "

The code is crashing on the first line. I'm pretty new and don't know where I'm going wrong.

Options: ReplyQuote


Subject
Written By
Posted
Retrieve data using checkboxes php mysql
June 09, 2010 01:03PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.