Click here to Skip to main content
14,453,230 members
Rate this:
Please Sign up or sign in to vote.
See more:
<html>
<head> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

</head>
<body>

<?php
session_start();
include("connectdb.php");
  if( isset( $_SESSION['name'])) {
      $name = $_SESSION['name']; 

         $query = "SELECT * from approvedhouse where name = '$name';";
          $result=mysqli_query($conn,$query);

echo '<div class="container">                   
  <h3>Application status</h3>                    
<table class="table table-hover" >
  <thead>
<tr> 
<th>Id</th>
<th>Name</th>
<th>Status</th>
<p></p>

      </tr>
 </thead> ';
$resultcount=mysqli_num_rows($result);
if(($resultcount)>0){
 while ($row =mysqli_fetch_array($result)){

 echo '<tr>
<td>'. $row["id"].'</td>     
<td>'. $row["name"].'</td>
<td>'.$row["message"].'</td>
</tr>';
}
echo'</table>';
}
else{
echo'<tr>
<td>'. $row["id"].'</td>     
<td>'. $row["name"].'</td>
<td>'.$row["message"].'</td>
</tr>';
}
}
?>
</body>
</html>


What I have tried:

i tried to print it is working for one type electricity and not working here

error at 48 49 50 lines --row--
Posted
Updated 29-Oct-19 11:08am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

After indenting your code correctly, you get
$resultcount=mysqli_num_rows($result);
if(($resultcount)>0){
	while ($row =mysqli_fetch_array($result)){ // $row is defined inside the loop

		echo '<tr>
		<td>'. $row["id"].'</td>
		<td>'. $row["name"].'</td>
		<td>'.$row["message"].'</td>
		</tr>';
	}
	echo'</table>';
}
else{
	echo'<tr>
	<td>'. $row["id"].'</td>
	<td>'. $row["name"].'</td>
	<td>'.$row["message"].'</td>
	</tr>'; // but you try to use it there too
}

the code just makes no sense.

Advice: Learn to indent properly your code, it show its structure and it helps reading and understanding. It also helps spotting structures mistakes.
<html>
    <head>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

    </head>
    <body>

        <?php
        session_start();
        include("connectdb.php");
        if( isset( $_SESSION['name'])) {
            $name = $_SESSION['name'];

            $query = "SELECT * from approvedhouse where name = '$name';";
            $result=mysqli_query($conn,$query);

            echo '<div class="container">
            <h3>Application status</h3>
            <table class="table table-hover" >
            <thead>
            <tr>
            <th>Id</th>
            <th>Name</th>
            <th>Status</th>
            <p></p>

            </tr>
            </thead> ';
            $resultcount=mysqli_num_rows($result);
            if(($resultcount)>0){
                while ($row =mysqli_fetch_array($result)){

                    echo '<tr>
                    <td>'. $row["id"].'</td>
                    <td>'. $row["name"].'</td>
                    <td>'.$row["message"].'</td>
                    </tr>';
                }
                echo'</table>';
            }
            else{
                echo'<tr>
                <td>'. $row["id"].'</td>
                <td>'. $row["name"].'</td>
                <td>'.$row["message"].'</td>
                </tr>';
            }
        }
        ?>
    </body>
</html>

Indentation style - Wikipedia[^]

Professional programmer's editors have this feature and others ones such as parenthesis matching and syntax highlighting.
Notepad++ Home[^]
ultraedit[^]
   
v2
Comments
Member 14636305 29-Oct-19 15:24pm
   
Thank you
Member 14636305 29-Oct-19 15:43pm
   
not cleared

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100