Search the Community
Showing results for tags 'php serach by date'.
-
So first of all there is no error msg at all but as i mentioned ther is something wrong i want to give my users the oppertunity to check on theyre historie i also want them to be able to check on there activities by an specific date though... so here is whats happening : First i try to hand over the var : if (isset($_POST['submit'])) { $IND_ = date( "Y-m-d", strtotime($_POST['y'] . "-" . $_POST['m'] . "-" . $_POST['d'])); echo $IND_; echo "<<<"; $ID = $userRow['userId']; $result = $crud->thouhistory($ID, $IND_); echo $IND_; echo "<<<"; #var_dump($result); } So far so good echos the correct date taht the user have been submitted... But then apperantly this happens in the crud.php public function thouhistory($UID,$IND) { #Abruf history für user echo " >0 "; echo $IND; if ($IND == "NONE") { try { echo " >1 "; echo $IND; $sql = $this->Db->prepare("SELECT * FROM history WHERE uid=:id"); $sql->bindparam(":id",$UID); $sql->execute(array(':id' => $UID)); $res = $sql->fetchAll(); if (count($res)) { return $res; } else { return 0; } return $row; } catch (PDOException $ex) { echo $ex->getMessage(); } } elseif($IND = "--") { return 0; } else { echo " >2 "; echo $IND; try { $sql = $this->Db->prepare("SELECT * FROM history WHERE uid=:id AND DATE_IND=:IND"); echo " >3 "; echo $IND; $sql->bindparam(":id",$UID); $sql->bindparam(":IND",$IND); $sql->execute(array(':IND' => $IND,':id' => $UID)); $res = $sql->fetchAll(); if (count($res)) { return $res; } else { return 0; } return $row; } catch (PDOException $ex) { echo $ex->getMessage(); } # history $CREDIT['CREDIT'] !!!!!!!!!!!!!!!!!!!!!!!!!!!!! } echos : >0 NONE >1 NONE (1970-01-01<<<)<-submited (>0 1970-01-01)crud (1970-01-01<<<)submitted but the hilarios point on this is that it displays : no items to display yet (return 0;) so in conclusion there is something wrong... Full code PHP CALL OUT : <?php ob_start(); session_start(); require_once '../dbconnect.php'; if( !isset($_SESSION['user']) ) { header("Location: index.php?reqlog"); exit; } $userRow=$crud->getuser($_SESSION['user']); $IND_ = "NONE"; $ID = $userRow['userId']; $result = $crud->thouhistory($ID, $IND_); if (isset($_POST['submit'])) { $IND_ = date( "Y-m-d", strtotime($_POST['y'] . "-" . $_POST['m'] . "-" . $_POST['d'])); echo $IND_; echo "<<<"; $ID = $userRow['userId']; $result = $crud->thouhistory($ID, $IND_); echo $IND_; echo "<<<"; #var_dump($result); } if (isset($_POST['submitall'])) { $IND_ = "NONE"; $ID = $userRow['userId']; $result = $crud->thouhistory($ID, $IND_); } ?> Crud--> public function thouhistory($UID,$IND) { #Abruf history für user echo " >0 "; echo $IND; if ($IND == "NONE") { try { echo " >1 "; echo $IND; $sql = $this->Db->prepare("SELECT * FROM history WHERE uid=:id"); $sql->bindparam(":id",$UID); $sql->execute(array(':id' => $UID)); $res = $sql->fetchAll(); if (count($res)) { return $res; } else { return 0; } return $row; } catch (PDOException $ex) { echo $ex->getMessage(); } } elseif($IND = "--") { return 0; } else { echo " >2 "; echo $IND; try { $sql = $this->Db->prepare("SELECT * FROM history WHERE uid=:id AND DATE_IND=:IND"); echo " >3 "; echo $IND; $sql->bindparam(":id",$UID); $sql->bindparam(":IND",$IND); $sql->execute(array(':IND' => $IND,':id' => $UID)); $res = $sql->fetchAll(); if (count($res)) { return $res; } else { return 0; } return $row; } catch (PDOException $ex) { echo $ex->getMessage(); } # history $CREDIT['CREDIT'] !!!!!!!!!!!!!!!!!!!!!!!!!!!!! } Html --> <div class="Space_0 Background_1"></div> <div class="HeZC"> <h4><?php echo $userRow['UzRI']; ?> this is your history</h4> <div class="HeZ Body_E01"> <ul> <?php if (isset($result)) { if ($result != 0) { foreach($result as $row) { echo "<li><p>" . $row['subject'] . "</p><p>". $row['DATE_'] . "</p></li>"; } } else { echo "<li><p>there are currently no items to display yet..." . "</p></li>"; } } ?> </ul> </div> </div> <div class="UcZc"> <div class="UcZ Body_E01"> <h4>Or maybe your searching for an specific entry... </h4> <form class="UcZf" method="POST"> <input type="number" name="y" maxlength="4" placeholder="Year"> <input type="number" name="d" maxlength="2" placeholder="Day"> <input type="number" name="m" maxlength="2" placeholder="Month"> <button name="submit">Search</button> <p>Or</p> <button name="submitall">display all</button> </form> </div>