looking for some solutions? You are welcome.

SOLVED: echo is showing output in page source instead of on page

AYUSH AGGARWAL:

I made a table in php and wanted to show the Id's in the dropdown select menu by making a separate file for php. So the code in main file is:

<?php include "functions.php";?>
<form action="login_update.php" method="post">
            <div class="form-group">
            <label for="username">username</label>
            <input type="text" name="username" class="form-control">
            </div>

            <div class="form-group">
            <label for="password">password</label>
            <input type="password" name="password" class="form-control">
            </div>

           <div class="form-group">
               <select name="id" id="">
                   <?php  

                        showAllData();
                   echo "<br>"."askfkldfjl;adfafladfdf";
                    ?>
               </select>
           </div>

            <input class="btn btn-primary" type="submit" name="submit" value="update">
       </form>

The code of functions.php is :

<?php 

function showAllData(){


    $connection = mysqli_connect('localhost','root','****','loginapp');
    if($connection){
        echo "We are connected. a=".$a."<br>";
    }else{
        die("Database connection failed");
    }
    $query = "SELECT * FROM users";
    $result = mysqli_query($connection,$query);
    if($result){
        echo("<br>"." <b><h6>We are successful</h6></b>");
    }
    else {        
        die("Query FAILED" . mysqli_error());
    }
    while($row = mysqli_fetch_assoc($result))  {
      $id = $row["id"];

      echo"<option value='$id'>$id</option>";


    }


}
?>

The expected output was : enter image description here

But the output is: enter image description here

So the top two lines in the above screenshot are not printing.

These lines are shown in the INSPECT ELEMENT in chrome.

enter image description here

I forgot to mention the echo command:

echo "<br>"."askfkldfjl;adfafladfdf";

below show all data is also not working.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent