0

I am new to MYSQL and i am trying to export my database to html, and put the data into specific html tables. I have looked around the site, but i cant get my code to work, can someone help me, and tell me if this code looks right ?

<?php

    $con=mysqli_connect("xxx","xxx","xxx","xxx","xxx");
    // Check connection
    if (mysqli_connect_errno())
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    $result = mysqli_query($con,"SELECT * FROM xxx");

    while($row = mysqli_fetch_array($result)) 
    {
        <tr>
            <th bgcolor="#3281c6">" . $row["PO_nummer"]. "</th>
            <th bgcolor="#3281c6">" . $row["Varenummer"]. "</th>
            <th bgcolor="#3281c6">" . $row["Produkt_beskrivelse_"]. "</th>
            <th bgcolor="#3281c6">" . $row["Antal"]. "</th>
    }

    mysqli_close($con);
?>
tausun
  • 2,154
  • 2
  • 24
  • 36
  • what is the issue (exception/incorrect UI rendering etc), highlighting will not force people here to assume your problems. – Anil Mar 08 '17 at 06:54
  • duplicate question: http://stackoverflow.com/questions/17902483/show-values-from-a-mysql-database-table-inside-a-html-table-in-a-page/17902527#17902527 – Abdul Rafay Mar 08 '17 at 06:55
  • It's a good start to write youre html and php with quotes, or outside – Finduilas Mar 08 '17 at 07:15

2 Answers2

0

You seem to be expecting an associative array and not a regular (numbered) array, in this case try:

while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) { // code }

0

Try and echo or print the html

echo "
<th bgcolor="#3281c6">" . $row["PO_nummer"]. "             </th>
<th bgcolor="#3281c6">" . $row["Varenummer"]. "</th>
<th bgcolor="#3281c6">" . $row["Produkt_beskrivelse_"]. "</th>
<th bgcolor="#3281c6">" . $row["Antal"]. "</th>";

And use single quotes here bgcolor='#3281c6'

Web Dev Guy
  • 1,693
  • 3
  • 18
  • 42