sql - Selecting multiple data from a database through PHP -


i have search form able retrieve username of user, can't figure out how return more that, want display first names , last names too.

below code @ minute works, when try , add in more variables, example if ($stmt = $connection->prepare ("select username users username ?")) doesn't return @ , asks insert search query.

i have tried if ($stmt = $connection->prepare ("select username users username %?%")) , like "%?%")), no results.

search.php

<?php  include 'connection.php'; if(isset($_post['searchsubmit'])) {     include 'searchform.php';         $name=$_post['name'];          if ($stmt = $connection->prepare ("select username users username ?"))          {             $stmt->bind_param('s', $name);             $stmt->execute();             $stmt->bind_result($personresult);             $stmt->fetch();             ?>             <center>                 <br>                 <h1>search results follows:</h1>                 <h2>usernames</h2>                 <br>             <?php              print_r($personresult);                ?>             </center>             <?php         }          else         {              echo  "<p>please enter search query</p>";          }      }  else      {      echo "not set!";      } 

you calling username .. need calling *

select * users username ? 

this personal script use:

<?php  $dbservername = "localhost"; $dbusername = "db_user"; $dbpassword = "pass"; $dbname = "db"; // create connection $conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname); if ($conn->connect_error) {     die("connection failed: " . $conn->connect_error); }  if (!empty($_post["username"])) { $username = $_post["username"]; } if (!empty($_post["password"])) { $password = $_post["password"]; }      $sql = "select * users";     $result = $conn->query($sql);    if ($result->num_rows > 0) {       while ($row = $result->fetch_assoc()) {      echo $row["username"] . " " . $row["firstname"] . " " .  $row["lastname"] . "<br>"; if ($row["username"] == $username && $row["password"] == $password) {             echo "success";             // more stuff here set session etc         } else {             $echo "incorrect username and/or password";         }      }     } ?> 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -