I want to create a simple program which function is: The user chooses a letter from a simple form and then the program generates all the elements from my "prestashop" named database which start with this letter. I created the database in phpmyadmin and created the code in php and in ajax. But I'm not sure if this piece of my code really makes the selection of the elements which start with the letter chosen from the user.An error occurs anyway. Here is my php code:
<?php
$q = intval($_GET['q']);/* 54-th row*/
$con = mysqli_connect('localhost','root','','prestashop');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"prestashop");
$sql="SELECT * FROM prestashop WHERE marca LIKE '".$q."'";
$result = mysqli_query($con,$sql);
echo "<table>
<tr>
<th>Marca</th>
<th>Descrizione</th>
</tr>";
while($row = mysqli_fetch_array($result)) {/* 70-th row*/
echo "<tr>";
echo "<td>" . $row['marca'] . "</td>";
echo "<td>" . $row['descrizione'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
Is there something I should change to make this works?
</div>