First post on the site, just read the FAQ (and I did!). Basically, what I would like to do is have a page with two dropdown forms. The first includes days of the week. The second includes times of the day. A third textbox (boolean) search would be nice as well as maybe some checkboxes to help filter, but those are unimportant at this point. The point of this script would be to output different venues onto an HTML/PHP into a grid or table by selecting data from each of the two search boxes. I have a SQL database created already, with all of the necessary tables, rows, columns laid out. I'm mostly just looking for some help in creating the search script, or even if someone has heard of s code snippet that may be available that does the same or similar thing. I can provide my failure of coding thus far, but would much prefer to start fresh. Anyway, thanks in advance for the help. I can provide any info if any is needed.
What you need depends on your level of expertise in writing the program. Is: "send the user's selections to a PHP page via AJAX to construct a SELECT query and return the results" enough for you? Or do you need the pages completely written for you? Or somewhere between the two extremes?
Ah, that does make sense Rukbat. Well, sorry for the delay - here's what I'm working with so far. It's a total disaster. It does return results, but they are not quite what I'm looking for. <?php $dbHost = 'localhost'; $dbUser = '_______'; $dbPass = '_______'; $dbDatabase = '________'; $con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error()); mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error()); $error = array(); $results = array(); $dropdown = empty($_POST['searchForm']); if (isset($_GET['search'])) { $searchTerms = trim($_GET['search']); $searchTerms = strip_tags($searchTerms); // remove any html/javascript. if (strlen($searchTerms) < 0) { $error[] = "Search must include at least one character, I mean come on..."; }else { $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection. } if (count($error) < 1) { $searchSQL = "SELECT id, name, address, url, 08000900, 09001000 FROM bingo WHERE "; $types = array(); $types[] = isset($_GET['name'])?"`name` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['08000900'])?"`08000900` LIKE '%{$searchTermDB}%'":''; $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked) if (count($types) < 1) $types[] = "`name` LIKE '%{$searchTermDB}%'"; // use the name as a default search if none are checked $searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `address`"; // order by title. $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if (mysql_num_rows($searchResult) < 1) { $error[] = "The search term provided {$searchTerms} yielded no results."; }else { $results = array(); // the result array while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "{$i}: {$row['address']}<br />{$row['url']}<br />{$row['name']}<br />{$row['wifi']}<br /><br />"; } } } } function removeEmpty($var) { return (!empty($var)); } ?> Code (markup): Basically, the search terms are based on military time starting at 8AM and ending at 2AM. I have yet to enter the days of the week. And here's the form (I'm testing the 08000900 and 09001000 times currently, the rest are placeholders): <?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?> <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm"> <select size="1" name="searchForm"> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="09001000" name="09001000" <?php echo isset($_GET['09001000']); ?> />9AM-10AM</option> <option value="10001100" name="10001100" <?php echo isset($_GET['10001100']); ?> />10AM-11AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> <option value="08000900" name="08000900" <?php echo isset($_GET['08000900']); ?> />8AM-9AM</option> </select> <input type="submit" name="submit" value="Search" /> </form> Code (markup): I'd be pretty happy if I could output even one of the times, because from there it's a matter of fill in the blank and to make it pretty with CSS. PHP is not my strong suit...
Hah, well no problem I guess. I've decided to go another route with this script - the new version is working AWESOME.