Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

Not able to read Mysql data on a web page using HTML

$
0
0

Have been trying to solve this problem for last week but even after going through many solutions and also trying many other things i am not able to understand the problem that is taking place in this one particular table of the database

This is the database that is interacting with Android App also.

My other database tables data are working but one of the table is not able to be fetched on the HTML page.

ERROR

[Database with tables(problem in order)][1]

[Table order structure][2]

[Error][3]

[1]: https://i.stack.imgur.com/36Ina.png [2]: https://i.stack.imgur.com/6jT85.png [3]: https://i.stack.imgur.com/b4Q4m.png

Error: Trying to get property of non-object in C:\xampp\htdocs\tutorial\trydata01\testt.php on line 39 0 result

PHP CODE:

<!DOCTYPE html>
<html>
<head>
    <title>Table with database</title>
    <style type="text/css">
        table {
            border-collapse: collapse;
            width: 100%;
            color: #d96459;
            font-family: monospace;
            font-size: 25px;
            text-align: left;
        }
        th{
            background-color: #588c7e;
            color: white;
        }
    </style>
</head>
<body>
    <table>
        <tr>
            <th>OrderId</th>
            <th>OrderStatus</th>
            <th>OrderPrice</th>
            <th>OrderDetail</th>
            <th>OrderComment</th>
            <th>OrderComment1</th>
            <th>UserPhone</th>
        </tr>
        <?php 
        $conn = mysqli_connect("localhost", "root", "", "wcfood01");
        if ($conn-> connect_error) {
            die("Connection failed:". $conn-> connect_error );
        }
        $sql = "SELECT * from order";
        $result = $conn-> query($sql);

        if ($result-> num_rows > 0) {
            while ($row = $result-> fetch_assoc()) {
                echo "<tr><td>". $row["OrderId"] ."</td><td>". $row["OrderStatus"] ."</td><td>". $row["OrderPrice"] . "</td><td>". $row["OrderDetail"] . "</td><td>". $row["OrderComment"] ."</td><td>". $row["OrderComment1"] ."</td><td>". $row["UserPhone"] ."</td></tr>";
            }
            echo "</table>";
        }
        else{
            echo "0 result";
        }

        $conn-> close();
        ?>
    </table>

</body>
</html>

Tried a lot many things but none of the already present solution works. Would be thankful if anyone could guide me through the problem


Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>