0

Hello guys I am getting crazy with this code, I need to fetch the data to php,displaying the records that I have already created in the following Myadminphpm0

I am fetching data from mysql to a page, i am not sure if the way im doing it is appropiate. I am having trouble with fetching values into sections of the page.[

TECHNO TABLE]1

THE CONEXION

<?php
$server_name ='localhost';
$db_user_name ='cl11-l2cert';
$db_password ='4RT!BBDUx';
$db_name ='cl11-l2cert';

$mysql= mysqli_connect($server_name, $db_user_name, $db_password, $db_name);


// Check connection
if (!$mysql) {
    die("Connection failed:");
}
//echo "Connected successfully";



?>

AND THIS IS THE CODE FROM THE TECHNO RECORDS LIST

<html>
<body><br><br>
        <?php
        include_once("conexion.php");
        $sql = ' SELECT * FROM `techno`';
        $result=mysqli_query($mysql,$sql);
        $techno=[];
                if (mysqli_num_rows($result) > 0) {
                $techno = mysqli_fetch_all($result,MYSQLI_ASSOC);
            }
                ?>

<div class="w3-row">
    <div class="w3-threequarter">
        <div class="w3-row-padding w3-center w3-margin-top">
                <?php
                foreach($techno as $x){ 
                    ?>
            <div class="w3-third">
                <div class="w3-card w3-container" style="min-height:460px">
                    <div class="w3-row">
                            <div class="w3-half">
                                    <p>Id:<?php echo $x['t_id']; ?></p>
                                    <p>Vynil:<?php echo $x['t_vynil']; ?></p>
                                    <p>Price:<?php echo $x['t_price']; ?></p>
                                    <img src="acid.><?php $x['t_img'] ?>.jpg" alt="image" width="50%">
                            </div>
                        </div>
                    </div>
                </div>
                <?php  }
                ?>
            </div>
        </div>
    </div>
    
</div>
</body>
</html>
  • 2
    PHPMyAdmin *is not* a database. It is a web interface for your MySQL database. – Jay Blanchard Jun 25 '20 at 14:16
  • 1
    `$result=mysqli_query($mysql, $sql);//assign the conecction variables to a string y tmbien asigna el $sql a la conexion y a ese paattron` is wrong. You do not need to do this because you assigned the connection to `$mysql`. `$result` would hold the return from te query, if you did one. Additionally, you do not have a query to retrieve data from the database. Where are you defining `$sql`? – Jay Blanchard Jun 25 '20 at 14:18

0 Answers0