Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have several functions one of them is used for echo into select value. In this select value you have options chosen from database(in my case article headers). And I want this select value to be processed after submiting and then echo-ing article header and article content.

I am working with PHPMyAdmin

Function

Searches database for selected value while also checking UserID(Checking UserID works fine everywhere lese)


function SearchPost($UserID){
    $conn = new PDO("mysql:host=$this->servername;dbname=$this->db", $this->usernameDB, $this->passwordDB);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $conn->exec("set names utf8");

    if(isset($_POST['Filter_Edit'])&& array_key_exists('Search', $_POST)){
      $st = $conn->prepare('SELECT PostName, PostContent FROM userposts WHERE PostName Like :PostName AND UserID Like :UserID');
      $st->bindParam('PostName', $PostName);
      $st->bindParam('UserID', $UserID);
      $st->execute();

      while($response = $st->fetch(PDO::FETCH_ASSOC)){
        $Name = $UserPost['PostName'];
        $YourPost = $UserPost['PostContent'];
        echo "somethingsomethingsomethingsomethingsomething";
          }
        }

      }

This is the site with the select tag and form

<form method="post">
    <select class = "SelectEdit" name= "Filter_Edit">
      <?php

      $log->SearchPost($_SESSION['UserID_Session']);
      ?>
    </select>

    <button type="submit" name="Search" class="ButtonSearch">Vyhledat</button>

    </form>

I don't know why it doesn't work and it doesn't print the echo in the function

Note: that Code is checked by script and there are no syntax errors

question from:https://stackoverflow.com/questions/65644858/function-that-is-used-for-searching-database-doesnt-work

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
134 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...