0
I have this code that shows all records as long as the initial number or letter is the same, but I wanted to show only the records that are exactly the same as those typed in the search field, or else show at most 5 records.
<?php
include 'conn.php';
$letter = $_GET["letter"];
$sql = "SELECT id,palavra from interpretacao_cpp where pronta != 0 AND palavra LIKE '".$letter."%'" ;
$result = $conn->query($sql);
$sql2 = "SELECT DISTINCT(SUBSTR(`palavra`, 1, 1)) As abc from interpretacao_cpp where pronta != 0 ORDER BY abc" ;
$result2 = $conn->query($sql2);
?>
OK Benilson, I opted for the limit 5 function, but the data appear in descending form (article 107, article 11, article 1), when it should be article 1, article 11, article 107... etc.
– Meireles
Usa order by together with limit, "order by desired field_asc limit 5"
– Benilson
Okay it’s already fixed, I thank you.
– Meireles