Jump to content

WyvernFrog

New Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by WyvernFrog

  1. I need help getting the data from phpMyAdmin to display in a php table:

    <?php
    $con = mysqli_connect('localhost', 'root', 'root', 'music_database');
     
    if(!$con)
    {
        die("Can not connect: " . mysqli_error($con));
    }
     
    if(!mysqli_select_db($con, 'music_database'))
    {
        echo 'Database Not Selected!';
    }
     
     
    $sql = "SELECT * FROM month1";
    $query = mysqli_query($con, $sql);
    if (!$query)
    { // add this check.
        die('Invalid query: ' . mysqli_error($con));
    } else{
     
        echo "<table border=1>
        <tr>
        <th>Song Title</th>
        <th>Song Artist</th>
        <th>Song Album</th>
        <th>Year Released</th>
        <th>Month Played</th>
        <th>Day of the Week Played</th>
        <th>Date Played</th>
        <th>Time Played</th>
        </tr>";
     
     
        while($record = mysqli_fetch_array($query))
        {
            echo "<tr>";
            echo "<td>" . $record['songtitle'] . "</td>";
            echo "<td>" . $record['songartist'] . "</td>";
            echo "<td>" . $record['songalbum'] . "</td>";
            echo "<td>" . $record['yearreleased'] . "</td>";
            echo "<td>" . $record['monthplayed'] . "</td>";
            echo "<td>" . $record['dayplayed'] . "</td>";
            echo "<td>" . $record['dateplayed'] . "</td>";
            echo "<td>" . $record['timeplayed'] . "</td>";
            echo "</tr>";
        }
      
        echo "</table>";
    }
    mysqli_close($con);
    ?>

    showrecords.php

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.