Database php

Asked 2 years ago, Updated 2 years ago, 77 views

The school server created a table on the DBMS and printed it on the web using echo and mysqli functions so that the table can be viewed on the web with php.

// Enter code here
<?php
require 'vars.php';

$con = mysqli_connect ($servername, $username, $password);
if(mysqli_connect_errno()) {
    echo "Failed to connect to MySQL : ".mysqli_connect_error();
}

mysqli_set_charset($con, "utf8");

if (!mysqli_select_db ($con, "kbstar21_db")) {
   echo "Something wrong with database selection".mysqli_error();
} } else {
   echo "Database selected successfully <BR><BR>";
}

$sql = "SELECT * FROM chicken";
echo ("<table width = 800 border = 1 cellpadding = 10>");

if ($result = mysqli_query($con, $sql)) {
    $a = mysqli_num_fields ($result);

    echo ("<tr>");
    while ($fieldinfo = mysqli_fetch_field($result)) {
       echo("<th>$fieldinfo->name</th>");
    }
    echo ("</tr>");
        while ($row = mysqli_fetch_row($result)) {

while ($row = mysqli_fetch_row($result)) {
        echo("<tr>");
        for ($i = 0 ; $i < $a ; $i++) {
            echo ("<td>$row[$i]</td>");
        }
        echo "</tr>";
    }
}

mysqli_free_result ($result);
mysqli_close ($con);
?>

If you look at the php door on the web, This is what happens, and I want to click on the name of the restaurant here so that the link appears. For example, if I click Nene Chicken, can I get it to the Nene Chicken homepage? I'm curious

database php mysql mysqli

2022-09-22 19:03

1 Answers

Add a column for the website address

echo " 
<a href=site address>Chickenhouse name column name</a> 
"; 

Why don't you try it?


2022-09-22 19:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.