php code in magento cms page

Job ID: 31458085

Budget: €8 – €30 EUR

I've written a simple php code to show query result from a db table (not the magento db). It has to show in a magento cms page but i can't get to work.

Here's the code of the table I have to show. Can someone help me?


<?php
$id=$_POST['tel'];
$con=mysqli_connect("mysite.com","username","password","db_name");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM ScolasticoMo WHERE tel= '" . $id . "'");

echo "<table border='1'>
<tr>
<th>stato</th>
<th>isbn</th>
<th>autore</th>
<th>titolo</th>
<th>editore</th>
<th>prezzo cop.</th>
<th>nuovo</th>
<th>usato</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['priority'] . "</td>";
echo "<td>" . $row['isbn'] . "</td>";
echo "<td>" . $row['autore'] . "</td>";
echo "<td>" . $row['titolo'] . "</td>";
echo "<td>" . $row['editore'] . "</td>";
echo "<td>" . $row['prezzo'] . "</td>";
echo "<td>" . $row['arrivato'] . "</td>";
echo "<td>" . $row['prenotato'] . "</td>";


echo "</tr>";
}
echo "</table>";

mysqli_close($con);
?>
Related categories: PHP Linux Magento MySQL HTML