Forum Moderators: coopster
Or I made a mistake in my form which looks like this:
<form method=POST action= "results.php">
<SELECT NAME = "catID" SIZE = "1">
<?
$query= " SELECT catID, catName FROM categories ORDER BY catID";
$result = mysql_query($query);
while($catID =mysql_fetch_array($result))
{
print("<OPTION VALUE =\"$catID[0]\">$catID[1]\n");
}
?>
</select><br><br>
Vul hier een ingredient in:<br><br>
<input name = "ingredienten" type = text>
<input type="submit" value= "zoek!">
<input type = "reset" value= "zoek opnieuw!">
</form>
or I cannot paas the results because I use two different tables in the query: the tablenames are 'categories' and 'recepten'
the queries on the results page look like this:
$numresults = mysql_query_test("SELECT recept AS RECEPTEN FROM recepten WHERE ingredienten LIKE
'%" . $param1 . "%' AND catID = ('$catID') "); // the query.
$numrows = mysql_num_rows($numresults); // Number of rows returned from above query.
and
$sql = mysql_query_test("SELECT recept AS RECEPTEN FROM recepten WHERE ingredienten LIKE
'%" . $param1 . "%' AND catID = ('$catID') ORDER BY recept limit $page, $limit ");
while ($row = mysql_fetch_array($sql)) {
$recept = $row['recept'];
echo $row['recept'] ."<br />";
and I try to link to next page with this:
if ($page!= 0) { // Don't show back link if current page is first page.
$back_page = $page - $limit;
echo("<a href=\"results.php?<?php echo(SID);?ingredienten=$param1&catId=$catID&page=$back_page&limit=$limit\">vorige</a> \n");}
for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it.
{
$ppage = $limit * ($i - 1);
if ($ppage == $page){
echo("<b>$i</b>\n");} // If current page don't give link, just text.
else{
echo("<a href=\"results.php?<?php echo(SID);?ingredienten=$param1&catID=$catID&page=$ppage&limit=$limit\">$i</a> \n");}
}
if (!((($page+$limit) / $limit) >= $pages) && $pages!= 1) { // If last page don't give next link.
$next_page = $page + $limit;
echo("<a href=\"results.php?<?php echo(SID);?ingredienten=$param1&catID=$catID&page=$next_page&limit=$limit\">volgende</a>");}
?>
I makes me mad that I cannot get it right. Can someone help?
foodstyling
print("<OPTION VALUE =\"$catID[0]\">$catID[1]\n");
The values are probably not what you expect. Try:
while($catrs =mysql_fetch_array($result))
{
print("<OPTION VALUE =\"".$catrs['catID']."\">".$catrs['CatName']."\n");
}
JAG