MySQL Forums
Forum List  »  PHP

Re: how to display database records on a web page?
Posted by: Vinoth K
Date: June 27, 2015 10:36AM

Mann Singh Wrote:
-------------------------------------------------------
> <?php
> $servername = "localhost";
> $username = "username";
> $password = "password";
> $dbname = "myDB";
>
> // Create connection
> $conn = new mysqli($servername, $username,
> $password, $dbname);
> // Check connection
> if ($conn->connect_error) {
> die("Connection failed: " .
> $conn->connect_error);
> }
>
> $sql = "SELECT id, firstname, lastname FROM
> MyGuests";
> $result = $conn->query($sql);
>
> if ($result->num_rows > 0) {
> // output data of each row
> while($row = $result->fetch_assoc()) {
> echo "id: " . $row["id"]. " - Name: " .
> $row["firstname"]. " " . $row["lastname"].
> "<br>";
> }
> } else {
> echo "0 results";
> }
> $conn->close();
> ?>


I tried the same thing in my website to display the database records. But i don't get any information. Can you please what is wrong in my page - Anna university Results

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.