php - Fetching value into form from MySql database -


i'm trying fetch value mysql database. have form want fetch emailid mysql db. please

<tr><td><b>email :</td><td><input type="text" name="txtemail" readonly value="<?php $name=$_session['usr_name']; $host="localhost"; // host name  $username="root"; // mysql username  $password=""; // mysql password  $db_name="test"; // database name   $conn=mysqli_connect($host,$username,$password) or die("cannot connect");   mysqli_select_db($conn,$db_name);  $result = mysqli_query($conn,"select emailid tabledetails     username='$name'");  echo $result; mysqli_close($conn); ?>"> </td> </tr> 

this working in local system:

try code per requirement:

<?php $name=$_session['usr_name'] $servername="localhost"; // host name  $username="root"; // mysql username  $password=""; // mysql password  $dbname="test"; // database name  // create connection $conn = mysqli_connect($servername, $username, $password, $dbname);  // check connection if ($conn->connect_error) {     die("connection failed: " . $conn->connect_error); }  else{ echo "connected successfully"; }  $res  = mysqli_query($conn,"select emailid tabledetails username='$name'");  while($row=mysqli_fetch_assoc($res)) { $rows = $row['email'];  print_r $rows;  echo $rows;    } ?> <tr><td><b>email :</td><td><input type="text" name="txtemail" readonly value="<?php echo $rows ?>"/> 

output:-

connected email :user 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -