'How can I set variable php and mysql code
I want to set a variable "name", I tried: if(isset($_POST['name'])), But not result.
I was also looking for other options but could not get results.
I have a PHP code:
  <?php
  $servername = "localhost";
  $username = "..";
  $password = "..";
  $dbname = "..";
  $conn = new mysqli($servername, $username, $password, $dbname);
  $response = array();
  $posts = array();
  $sql = "SELECT name, addres, status, date  FROM silknet WHERE name='test'";
  $result=mysqli_query($conn,$sql);
  while($row=mysqli_fetch_array($result)) { 
     $name=$row['name']; 
     $addres=$row['addres']; 
     $status=$row['status'];
     $date=$row['date'];
  $response[] = array('name'=> $name, 'addres'=> $addres, 'status'=>$status, 
  'date'=>$date);
  } 
  echo json_encode($response);
  ?> 
Solution 1:[1]
Add to the top:
$name = $_POST['name'];
And edit this line as:
 $sql = "SELECT name, addres, status, date  FROM silknet WHERE name='$name'";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | sezer iltekin | 
