Jump to content

spooooky

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

spooooky's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. it´s supposed to be kind of a search function. u select different categories and a date and then u get several results. in my case those results are mostly events or sth. so they have a start date and an end date. my search function works perfect without date selected. but anyway the user should be able to select also by date. so he chooses a date from my drop down menu and only those results should be returned, that match the categories AND the selected user date must be in between the start and end date of those results. i try to handle this with the sql query: SELECT * FROM Angebot WHERE Von <= $help <= Bis AND Angebotskategorie=\'$filter[0]\' OR Angebotskategorie=\'$filter[1]\' OR ... where \"Angebot\" is the event table, \"Von\" the start and \"Bis\" the end date $help is the date selected by user in this format: YYYY-MM-DD
  2. Hi folks! I´m desperate. I\'m trying to compare dates from a user input (drop down menu) with those of a mysql DB in \"date\" format. I force the user input to be the same format (YYYY-MM-DD) as those in my DB. I tried all kinds of combinations of \"<>=\", sometimes i get all results, sometimes none and sometimes only those that dont even have a date (then 0000-00-00). What am I doing wrong?! thx in advance! your site did already help me out often enough! <?php $filter=$_POST[\'checkboxes\']; // Zuweisung der Auswahl aus "filtercheck_DHR.php" to array $andtime=$_POST[\'zeit\']; if ($andtime) { $D=$_POST[\'tag\']; // format of \'tag\': XX $M=$_POST[\'monat\']; // format of \'monat\': XX $Y=$_POST[\'jahr\']; // format of \'jahr\': XXXX $help="$Y-$M-$D"; $date="Von <= $help <= Bis"; // sql query part in var $date // (for timecheck: $help should lie in between start and end date of matching offers) // "Von" and "Bis" in \'date\' file type } $count=count($_POST[\'checkboxes\']); switch($count) { // sql query part for var $cat case 1: $cat="Angebotskategorie=\'$filter[0]\'"; break; case 2: $cat="Angebotskategorie=\'$filter[0]\' OR Angebotskategorie=\'$filter[1]\'"; break; case 3: $cat="Angebotskategorie=\'$filter[0]\' OR Angebotskategorie=\'$filter[1]\' OR Angebotskategorie=\'$filter[2]\'"; break; case 4: ... } $select="SELECT * FROM Angebot WHERE "; $order="ORDER BY Angebotskategorie"; if ($andtime) { // $sql="$select ($date) AND ($cat)"; } else { $sql="$select $cat $order"; } echo ($sql); $link_id=mysql_connect("localhost","....") or die("keine Verbindung"); // DB connection mysql_select_db("0251_reiseshop") or die("Datenbankauswahl nicht möglich"); $result=mysql_query($sql, $link_id); // SQL query if ($result) { // output results $number=mysql_num_rows($result); echo "Ihre Auswahl liefert $number Ergebnis(se)"; echo "<TABLE BORDER=1>"; while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<TR><TD>"; echo implode("<TD>",$row); echo "</TR>"; } echo "</TABLE>"; } else { echo "<P>".mysql_error($link_id); } mysql_close($link_id); // DB disconnection ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.