Hello scripterfriends,
I'm working on a project where I need to sort a row in alphabetical order. After searching for some solutions I didn't find the one I was looking for. Lets say I need only the products that start with the letter "F". I want it like the picture below: https://gyazo.com/488ccc8fd2beaadbc96d687938e5a6ff
I need to be able to click the F and let it only show the product the start with the F.
The code I have so does the trick but I need to change the code in order to get another letter. This is the code I have so far:
<?php
require_once 'config.php';
try {
$sQuery = "SELECT receptnummer, receptnaam, receptingredient, receptbereidingstijd, receptbereidingswijze, receptcategorie, receptbenodigdheden, receptserveertips, klantnummer
FROM recept
WHERE receptnaam LIKE '%f%' ORDER BY receptnaam";
$oStmt = $db->prepare($sQuery);
$oStmt->execute();
if ($oStmt->rowCount() > 0) {
echo '<table border="2">';
echo '<thead>';
echo '<td>receptnummer</td>';
echo '<td>receptnaam</td>';
echo '<td>receptingredient</td>';
echo '<td>receptbereidingstijd</td>';
echo '<td>receptbereidingswijze</td>';
echo '<td>receptcategorie</td>';
echo '<td>receptbenodigdheden</td>';
echo '<td>receptserveertips</td>';
echo '<td>klantnummer</td>';
while ($aRow = $oStmt->fetch(PDO::FETCH_ASSOC)) {
echo '<tr>';
echo '<td>' . $aRow['receptnummer'] . '</td>';
echo '<td>' . $aRow['receptnaam'] . '</td>';
echo '<td>' . $aRow['receptingredient'] . '</td>';
echo '<td>' . $aRow['receptbereidingstijd'] . '</td>';
echo '<td>' . $aRow['receptbereidingswijze'] . '</td>';
echo '<td>' . $aRow['receptcategorie'] . '</td>';
echo '<td>' . $aRow['receptbenodigdheden'] . '</td>';
echo '<td>' . $aRow['receptserveertips'] . '</td>';
echo '<td>' . $aRow['klantnummer'] . '</td>';
echo '</tr>';
}
echo '</table>';
} else {
echo 'helaas, geen gegevens gevonden';
}
} catch (PDOException $e) {
$sMsg = '<p>
Regelnummer: ' . $e->getLine() . '<br/>
Bestand: ' . $e->getFile() . '<br/>
Foutmelding: ' . $e->getMessage() . '
</p>';
trigger_error($sMsg);
}
$db = null;
?>
Can someone help me out on this one???
Thanks in advance,
DigitalDentist