All right, I have been working on this problem for several hours now to no avail. Basically what I have is a page that calls sponsors at random from a database.
Now, there is also a State search where you choose a state and the address is automatically loaded for you.
When the search is done, the client wants the sponsors to only be from that state. When there is a state searched, the code does pull sponsors from that state, but it pulls nothing when the search hasn't been performed.
What I have for the sponsors page is this:
if (isset($_GET['state'])) {
$state = $_GET['state'];
$aq = mysql_query("SELECT name,link,description,date FROM sponsors WHERE enabled = 'Y' AND state = '$state' ORDER BY rand() LIMIT 10");
$ar = mysql_num_rows($aq);
$ac = 0;
}
else {
$aq = mysql_query("SELECT name,link,description,date FROM sponsors WHERE enabled = 'Y' and ORDER BY rand() LIMIT 10");
$ar = mysql_num_rows($aq);
$ac = 0;
}
while($ac < $ar) {
$name = mysql_result($aq,$ac,'name');
$link = mysql_result($aq,$ac,'link');
$desc = mysql_result($aq,$ac,'description');
echo "<span class='smallTXT'><a href='$link' alt='$desc' target='_Blank' class='smallTXT'>$name<p></span>";
$ac++;
}
Yet I recieve no sponsers called, as if the $_GET('state') is always set.
Any ideas?
Also, the search isn't posted like a form. In case you need it, this is the code:
$sres = mysql_query("SELECT * FROM state ORDER BY state_code ASC");
$srow = mysql_num_rows($sres);
$scoo = 0;
echo "<select name='site' size=1 onChange='javascript:formHandler()' class='FormFields' tabindex='1' hspace='3'>";
echo "<option value='00' selected>SELECT YOUR STATE</option>";
while($scoo < $srow) {
$s_code = mysql_result($sres,$scoo,'state_code');
$state = mysql_result($sres,$scoo,'state_name');
echo "<option value='?p=search&search=state&state=$s_code'>$state</option>";
$scoo++;
}
echo "</select>";