I'm really new to HTML/PHP and I want to build a simple website that returns the data from my MySQL database in form of a table..
My code looks like this for now:
<?php
$server = mysql_connect("server", "username", "password");
$db = mysql_select_db("ni354077_2sql1", $server);
$query = mysql_query("SELECT * FROM Jobs");
?>
<table>
<tr>
<td>AuftragsID</td>
<td>Startort</td>
<td>Zielort</td>
<td>Gewicht</td>
<td>Fracht</td>
</tr>
<?php
while ($row = mysql_fetch_array($query)) {
echo "<tr>";
echo "<td>".$row[AuftragsID]."</td>";
echo "<td>".$row[Startort]."</td>";
echo "<td>".$row[Zielort]."</td>";
echo "<td>".$row[Gewicht]."</td>";
echo "<td>".$row[Fracht]."</td>";
echo "</tr>";
}
?>
</table>
However it doesn't seem to be working properly. My table is full of "echo (..)" here is a Picutre of what it looks like:
Am I missing something ? I'm coming from C# WinForms and am confused with that.
use this u have missed single quotes around php values, put like below
<?php
while ($row = mysql_fetch_array($query)) {?>
<tr>
<td><?php echo $row['AuftragsID'];?></td>
<td><?php echo $row['Startort'];?></td>
<td><?php echo $row['Zielort'];?></td>
<td><?php echo $row['Gewicht'];?></td>
<td><?php echo $row['Fracht'];?></td>
</tr>
<?php } ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With