what's wrong with this code?
I've a from on a page using post and two input fields (locatie, a pull down list with locations) and cursus (name of a course)
the script works and gives back the right data, but the next previous buttons loose the query
how can I solve this problem?
additionally, the field cursus (or course in English) is of the type fulltext search, how do I activate this as I understand the use of the % signs stops mysql from using the index
when you know that we have quite some traffic and 600+ records with lots of information, I don't want to get errors like too many connections to database, etc ...
<?php
mysql_connect (localhost, ******, *******);
mysql_select_db (*******);
//anatal records per pagina
$limit=20;
$numresults=mysql_query("SELECT * FROM opleiding WHERE cursus LIKE '%$cursus%' AND locatie = '$locatie'");
$numrows=mysql_num_rows($numresults);
//bypass offset
if (empty($offset)) {
$offset=0;
}
$result=mysql_query("SELECT * FROM opleiding WHERE cursus LIKE '%$cursus%' AND locatie = '$locatie' ORDER by start limit $offset,$limit");
while ($row = mysql_fetch_array($result)) {
print ("<tr>");
print ("<td width=55%>");
print $row["cursus"];
print (" ");
print ("</td>");
print ("<td width=15% align=center>");
list($year, $month, $day) = explode("-", $row["start"]);
echo $day;
print ("/");
echo $month;
print ("/");
echo $year;
print (" ");
print ("</td>");
print ("<td width=15% align=center>");
print ("<a href=\"http://www.syntra-ab.be/detail.php?id=$row[id]\">");
print ("details");
print ("</a>");
print ("</td>");
print ("<td width=15% align=center>");
print ("<a href=\"http://www.syntra-ab.be/inhoud.php?id=$row[id]\">");
print ("inhoud/doelgroep");
print ("</a>");
print ("</td>");
}
print ("</table>");
print ("<br>");
// geen vorige pagina op pagina 1
if ($offset >= 1) {
$prevoffset = $offset - 20;
print "<a href=\"$PHP_SELF?offset=$prevoffset\">VORIGE</a> - \n";
}
$pages=intval($numrows/$limit);
if ($numrows%$limit) {
$pages++;
}
// geen link op huidige pagina
for ($i = 1; $i <= $pages; $i++) {
$newoffset = $limit*($i-1);
if ($newoffset == $offset) {
print "pag. $i - \n";
} else {
print "<a href=\"$PHP_SELF?offset=$newoffset\">pag. $i</a> -\n";
}
}
// geen volgende pagina op laatste pagina
if (! ( ($offset/$limit) == ($pages - 1) ) && ($pages != 1) ) {
$newoffset = $offset+$limit;
print "<a href=\"$PHP_SELF?offset=$newoffset\"> VOLGENDE</a><p>\n";
}
?>