De data kan ik dan laten zien.
Nu wil ik het in een tabel netjes krijgen dat lukt ook, maar alleen maar 1 regel.
Het kunnen er 3 of vele malen meer zijn.
Ik wil dus afhakelijk van de zoekresultaten alle rijen tonen in een tabel.
Onderstaande code heb ik tot nu toe.
<section>
<?php
include ("db_config.php");
$output = '';
if(isset($_POST['search'])) {
$searchq = $_POST['search'];
$searchq = preg_replace ("#[^0-9a-z]#i","",$searchq);
$query = mysql_query("SELECT * FROM hoofdartikel WHERE merk LIKE '%$searchq%' OR type LIKE '%$searchq%'") or die ("Kan niet zoeken!");
$count = mysql_num_rows ($query);
if($count == 0){
$output = 'Helaas geen resultaten';
}else{
while($row = mysql_fetch_array($query)) {
$merk = $row['merk'];
$type = $row['type'];
$omschrijving = $row['omschrijving'];
$artnr = $row['artnr'];
$alternatief = $row['alternatief'];
$id = $row['id'];
$output .= '<div>'.$merk.' '.$type.' '.$omschrijving.' '.$artnr.' '.$alternatief.'</div>';
}
}
}
?>
</section>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>zoeken</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div>
<form action="zoeken.php" method="post">
<input type="text" name="search" placeholder="Zoek naar artikelen.."/>
<input type="submit" value=">>" />
</form>
<table border='1'>
<tr>
<th>Artikelnummer</th>
<th>Merk</th>
<th>Type</th>
<th>Omschrijving</th>
<th>Alternatief</th>
</tr>
<?php
//print("$output");
print "<tr><td> $artnr </td><td> $merk </td><td> $type </td><td> $omschrijving </td><td> $alternatief </td></tr>\n";
?>
</body>
</html>