Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why is my search returning commas as values

Status
Not open for further replies.

dunskii

Programmer
Sep 14, 2001
107
AU
Hi all,

does anyone know why my seaarch is returning commas as the value

heres my code,

<?php

$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;);
mysql_select_db(&quot;fjc&quot;,$db);

$orderby=Lst_name;
$stories_per_page=10;
$limit = $stories_per_page;

if (!$page):
$offset = 0;
else :
$offset = (($stories_per_page * $page)-$stories_per_page);
endif;

$sqlstr = &quot;SELECT barristers.lst_name, barristers.fst_name, barristers.prefered, areas.area FROM barristers, areas WHERE barristers.Lst_name LIKE '%$bar_search%' OR barristers.Fst_name LIKE '%$bar_search%' OR barristers.prefered LIKE '%$bar_search%'ORDER BY '$orderby'&quot;;
$sqlstr_wo_limits = $sqlstr;
$sqlstr.= &quot; LIMIT &quot;.$offset.&quot;, &quot;.$limit;

$result = mysql_query($sqlstr) or die(&quot;FAILED:&quot;.mysql_error().&quot;for&quot;.$querystring.&quot;\n&quot;);
$cols = 3;
$counter = 1;
do {

print '<table width=\&quot;100%\&quot; cellspacing=\&quot;4\&quot;>
<tr>';
while ($myrow = mysql_fetch_array($result)) {
if (is_int($counter / $cols)) {
print '<td>
<table width=\&quot;100%\&quot;>
<tr>
<td>
<span class=\&quot;text\&quot;>'. $myrow[&quot;barristers.lst_name&quot;] .', '. $myrow[&quot;barristers.fst_name&quot;] .', '. $myrow[&quot;barristers.qc_bc&quot;] .'</span>
</td>
<td>

</td>
</tr>
</table>


</td>
</tr>';
}
else {
print '<tr><td><span class=\&quot;text\&quot;>'. $myrow[&quot;barristers.lst_name&quot;] .', '. $myrow[&quot;barristers.fst_name&quot;] .', '. $myrow[&quot;barristers.qc_bc&quot;] .'</span></td>';
}
$counter++;
}
print '</tr></table></center>';


} while ($myrow = mysql_fetch_array($result));

$total_records = mysql_query($sqlstr_wo_limits) or die(&quot;FAILED:&quot;.mysql_error().&quot;for&quot;.$querystring.&quot;\n&quot;);
$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.=&quot;Page : &quot;;
while ($i <= $page_count) {

if($i != $page)

{

$output_string.=&quot;<a href=\&quot;$PHP_SELF?page=$i\&quot;>$i</a>\n&quot;;

} else {$output_string.=&quot;$i<br>&quot;;}

$i++;
}

if ($page < $page_count) {
$output_string.=&quot;<a href=\&quot;$PHP_SELF?page=$nextpage\&quot;>&quot;;
$output_string.=&quot;Next $stories_per_page record(s)...</a>&quot;;
} else {
$output_string.=&quot;No more records to display!&quot;;
}
?>

thanks,

dunskii
 
when i ran the query in mysql it didnt show any results
 
hello
check this part of code

<span class=\&quot;text\&quot;>'. $myrow[&quot;barristers.lst_name&quot;] .', '. $myrow[&quot;barristers.fst_name&quot;] .', '. $myrow[&quot;barristers.qc_bc&quot;] .'</span>


since there are no matching records for the query (u have checked this in mysql) $myrow[&quot;barristers.lst_name&quot;] , $myrow[&quot;barristers.fst_name&quot;] and
$myrow[&quot;barristers.qc_bc&quot;] will be empty so it just prints the comma which are appended to the string.

cheers
spookie
 
there is a matching record in the table but it isnt showing the result.

thanks,

ad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top