I have (at least) two issues that are perplexing me.
- My loop is not working, it is giving me the one record (the first) 3 times.
The query works.
$county='Montgomery County';
mysql_select_db($database_alphabb, $alphabb);
$query_Recordset1 = "SELECT * FROM attorney WHERE ('county'||'county_2'||'county_3') = '$county' ";
$Recordset1 = mysql_query($query_Recordset1, $alphabb) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
The Loop
<?php
$counter = 0;
$max = 3;
while (($totalRows_Recordset1 > 0) && ($counter < $max)){ // Show if recordset not empty ?>
<?php
$counter++;
echo '<br />';
echo "$row_Recordset1[logo]".'<br />';
echo '<h4>'. "$row_Recordset1[law_firm]".'</h4>';
echo '<h5>'. "$row_Recordset1[fname]" . " $row_Recordset1[mint] " . " $row_Recordset1[lname]". ' ESQ'.'</h5>'.'<br />';
echo "$row_Recordset1[street]".'<br />'
. " $row_Recordset1[city]"
. " $row_Recordset1[state]"
. " $row_Recordset1[zip]";
echo '<br /><br />';
echo "$row_Recordset1[phone]".'<br />';
echo "<a href=$row_Recordset1>".' Law Firm Web Site'.'</a>'.'<br />';
echo '<hr />';
?>
<?php } ?>
The second issue is really weird in that I removed the first record’s ‘county’ so it should not show up in the result, but it does. I ran the query through phpmyadmin and the first record STILL shows up, even though it has no county listed and should be bypassed by the query. The mysql query gives me 3 results (total in the table)
The mysql query:
SELECT*
FROM attorney
WHERE (
'county' ||'county_2' ||'county_3'
) ='Montgomery County'
LIMIT 0 , 30
Can anyone point me in the right direction?
Gary