Hi there,
I'm trying to create an advanced search process, where the data has been collect via text boxes and checkboxes.
With the results, it will be limited by the user.
The errors say that there is some thing wrong with the sql (in red)...but i cant see it
Heres the code i'm using;
<?
function db_connect() {
$db = mysql_connect("localhost", "root"
mysql_select_db("fjc",$db);
return $db;
}
$order_by = $orderby;
$stories_per_page=$per_page;
$limit = $stories_per_page;
$result = mysql_query("SELECT * FROM barristers, areas, admissions WHERE (barrsiters.Lst_name LIKE '%$barrister%') OR (barristers.Fst_name LIKE '%$barrister%') OR (admissions.Admission LIKE '%$admission%') OR (areas.Area LIKE '%$area%') ORDER BY '$order_by'",$db);
return $result;
if (!$page):
$offset = 0;
else :
$offset = (($stories_per_page * $page)-$stories_per_page);
endif;
$sqlstr = "SELECT * FROM barristers, areas, admissions WHERE (barrsiters.Lst_name LIKE '%$barrister%') OR (barristers.Fst_name LIKE '%$barrister%') OR (admissions.Admission LIKE '%$admission%') OR (areas.Area LIKE '%$area%') ORDER BY '$order_by'";
$sqlstr_wo_limits = $sqlstr;
$sqlstr.= " LIMIT ".$offset.", ".$limit;
$result = query_database($sqlstr);
print '<center><table width=\"100%\" align=\"center\" cellspacing=\"0\"><tr>';
do {
print '<td align="left"><li><a href="../barristers/details.php?bar_id=$bar_id"><spa n class=\"text\">'. $myrow["barristers.lst_name"] .', '. $myrow["barristers.fst_name"] .', '. $myrow["barristers.qc_bc"] .'</span></a></td></tr><tr>' ;
print '<td align="left"><li><a href="../barristers/details.php?bar_id=$bar_id"><spa n class=\"text\">'. $myrow["barristers.lst_name"] .', '. $myrow["barristers.fst_name"] .', '. $myrow["barristers.qc_bc"] .'</span></a></td>';
} while ($myrow = mysql_fetch_array($result));
print '</tr></table></center>';
$total_records = query_database($sqlstr_wo_limits);
$count = mysql_num_rows($total_records);
if(!$page) {$page=1;}
$offset = ($page-1)*$stories_per_page;
$page_count = ($count-($count%$stories_per_page)) / $stories_per_page + 1;
$nextpage=$page+1;
$i = 1;
$output_string.="Page : ";
while ($i <= $page_count) {
if($i != $page)
{
$output_string.="<a href=\"$PHP_SELF?page=$i\">$i</a>\n& quot;;
} else {$output_string.="<b>$i</b>";}
$i++;
}
if ($page < $page_count) {
$output_string.="<a href=\"$PHP_SELF?page=$nextpage\">";
$output_string.="Next $stories_per_page record(s)...</a>";
} else {
$output_string.="No more records to display!";
}
?>
The errors say that there is some thing wrong with the sql...but i cant see it
Thanks for your help...
dunskii
I'm trying to create an advanced search process, where the data has been collect via text boxes and checkboxes.
With the results, it will be limited by the user.
The errors say that there is some thing wrong with the sql (in red)...but i cant see it
Heres the code i'm using;
<?
function db_connect() {
$db = mysql_connect("localhost", "root"
mysql_select_db("fjc",$db);
return $db;
}
$order_by = $orderby;
$stories_per_page=$per_page;
$limit = $stories_per_page;
$result = mysql_query("SELECT * FROM barristers, areas, admissions WHERE (barrsiters.Lst_name LIKE '%$barrister%') OR (barristers.Fst_name LIKE '%$barrister%') OR (admissions.Admission LIKE '%$admission%') OR (areas.Area LIKE '%$area%') ORDER BY '$order_by'",$db);
return $result;
if (!$page):
$offset = 0;
else :
$offset = (($stories_per_page * $page)-$stories_per_page);
endif;
$sqlstr = "SELECT * FROM barristers, areas, admissions WHERE (barrsiters.Lst_name LIKE '%$barrister%') OR (barristers.Fst_name LIKE '%$barrister%') OR (admissions.Admission LIKE '%$admission%') OR (areas.Area LIKE '%$area%') ORDER BY '$order_by'";
$sqlstr_wo_limits = $sqlstr;
$sqlstr.= " LIMIT ".$offset.", ".$limit;
$result = query_database($sqlstr);
print '<center><table width=\"100%\" align=\"center\" cellspacing=\"0\"><tr>';
do {
print '<td align="left"><li><a href="../barristers/details.php?bar_id=$bar_id"><spa n class=\"text\">'. $myrow["barristers.lst_name"] .', '. $myrow["barristers.fst_name"] .', '. $myrow["barristers.qc_bc"] .'</span></a></td></tr><tr>' ;
print '<td align="left"><li><a href="../barristers/details.php?bar_id=$bar_id"><spa n class=\"text\">'. $myrow["barristers.lst_name"] .', '. $myrow["barristers.fst_name"] .', '. $myrow["barristers.qc_bc"] .'</span></a></td>';
} while ($myrow = mysql_fetch_array($result));
print '</tr></table></center>';
$total_records = query_database($sqlstr_wo_limits);
$count = mysql_num_rows($total_records);
if(!$page) {$page=1;}
$offset = ($page-1)*$stories_per_page;
$page_count = ($count-($count%$stories_per_page)) / $stories_per_page + 1;
$nextpage=$page+1;
$i = 1;
$output_string.="Page : ";
while ($i <= $page_count) {
if($i != $page)
{
$output_string.="<a href=\"$PHP_SELF?page=$i\">$i</a>\n& quot;;
} else {$output_string.="<b>$i</b>";}
$i++;
}
if ($page < $page_count) {
$output_string.="<a href=\"$PHP_SELF?page=$nextpage\">";
$output_string.="Next $stories_per_page record(s)...</a>";
} else {
$output_string.="No more records to display!";
}
?>
The errors say that there is some thing wrong with the sql...but i cant see it
Thanks for your help...
dunskii