Calling data from mysql into a table using PHP

php
mysql

#1

I’m having a really hard time pulling data from mysql database into a table. Ive gone through multiple tutorials and I am really spinning my wheels. Any guidance would be very appreciated. Here is the code (below). The table worked before as desired but when I tried to tie in the mysql database the wheels came off.

    table {
    border-radius: 20px;
    border-spacing: 0;
    border: 1px solid #6796C8;
    font: normal 12px Helvetica,sans-serif,Arial;
    }

    table thead th {
        background-color: #d6d4d1;
        border: 1px solid #6796C8;
        border-spacing: 0;
        color: #e04422;
        padding: 10px;
        text-align: left;
        text-shadow: 1px 1px 1px #fff;
    }

    table tbody td {
        border: 1px solid #6796C8;
        border-spacing: 0;
        color: #333;
        padding: 10px;
        text-shadow: 1px 1px 1px #fff;
    }
    
    table {
      overflow: hidden;
    }
    
    tr:hover {
      background-color: #d6d4d1;
    }
    
    td, th {
      position: relative;
    }
    
    td:hover::after,
    th:hover::after {
      content: "";
      position: absolute;
      background-color: #d6d4d1;
      left: 0;
      top: -5000px;
      height: 10000px;
      width: 100%;
      z-index: -1;
    }
    
    table thead th:first-child {
        border-radius: 20px 0 0 0;
    }
    
    table thead th:last-child {
        border-radius: 0 20px 0 0;
    }
    	
    table tbody tr:last-child td:first-child {
        border-radius: 0 0 0 20px;
    }
    
    table tbody tr:last-child td:last-child {
        border-radius: 0 0 20px 0;
    }
    
    h2 {
        color: #6796C8;
        text-shadow: 1.5px 1.5px 1.5px #d6d4d1;
    }
    </style>
</head>

Delaware Chancery Appraisal Opinions:

<?php $servername = "127.0.0.1"; $username = "ghex"; $password = ""; $dbname = "c9"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT case_name, target_entity, judge, year, deal_px, award, prem FROM base_case_info"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo ""; while($row = $result->fetch_assoc()) { echo ""; } echo "
Case Name Target Judge Year Deal Price Award Prem/(Disc)
".$row["case_name"]." ".$row["target_entity"]." ".$row["judge"]." ".$row["year"]." ".$row["deal_px"]." ".$row["award"]." ".$row["prem"]."
"; } else { echo "0 results"; } $conn->close(); ?>

#2

What exactly is the problem you’re having? Are you seeing any errors? Or is it simply not giving you any data?


#3

Thanks for your response.
I just get back the header and then “0 results” like this —>

Delaware Chancery Appraisal Opinions:

0 results


#4

And can you confirm that you are connecting to the correct database, querying the correct table, and there is actually data in that table?


#5

yes - that is all true


#6

Would you be okay with me joining your workspace (if you can provide the link) and trying to diagnose the problem?


#7

i would have been totally fine but i got it working. No clue how but working as expected now. Thanks for your willingness to help me out