|
Search Results.
";
}
//select all of the plumbers with these skills
if (count($varSkills) > 1)
{
$strSQL = "SELECT * FROM Members WHERE userID IN (SELECT m.userid FROM Members m, MemberSkills ms WHERE ms.userID = m.UserID AND m.MemberStatus <> 'DEL' AND ms.skill_code IN (" . $strSkills . ") GROUP BY m.userid HAVING COUNT(m.userid) > 1)";
}
else
{
$strSQL = "SELECT m.* FROM Members m, MemberSkills ms WHERE ms.userID = m.UserID AND m.MemberStatus <> 'DEL' AND ms.skill_code IN (" . $strSkills . ")";
}
//echo $strSQL;
$result = mysql_query($strSQL, $db);
if(!$result) die("Sorry, but we were unable to query the database at this time.0");
if (mysql_num_rows($result) <= 0)
{
echo ("Sorry, but your selection did not return any results.");
exit;
}
//now see if we have a postcode
if (trim($varPostcode) != "")
{
//now, make a postcode list of all of those plumbers
while($row = mysql_fetch_row($result)) {
if (trim($row[14]) != "")
{
$postcodeList = $postcodeList . "'" . $row[14] . "'" . ",";
}
}
//remove the last comma
$postcodeList = substr($postcodeList,0,strlen($postcodeList)-1);
//if we have a postcode, we need to work out which are the closes postcodes to us
//if we are here we have a db connection
//so select the appropriate schema
mysql_close($db);
$db = mysql_connect("www.preflight.com.au", "preflite_postcod@www.preflight.com.au", "po54c06e5");
mysql_select_db("preflite_postcodes", $db);
$strSQL = "select topc as postcode, distkm from postcode_distance where frompc = '" . $varPostcode . "' and topc in (" . $postcodeList . ") UNION select frompc as postcode, distkm from postcode_distance where frompc in (" . $postcodeList . ") and topc = '" . $varPostcode . "' order by distkm limit 10";
//echo $strSQL;
$result = mysql_query($strSQL, $db);
if(!$result) die("Sorry, but we were unable to query the database at this time. " . mysql_error());
if (mysql_num_rows($result) <= 0)
{
echo ("Sorry, but your selection did not return any results.");
exit;
}
while($row = mysql_fetch_row($result)) {
$postcodeSelList = $postcodeSelList . "'" . $row[0] . "'" . ",";
}
//remove the last comma
$postcodeSelList = substr($postcodeSelList,0,strlen($postcodeSelList)-1);
mysql_close($db);
}
//if we have postcodes back in the postcodesellist, it means we have a postcode and we have to redo the query
//otherwise it means we do not have a postcode and we can ignore the
//select all of the plumbers with these skills
if ($postcodeSelList != "")
{
if (count($varSkills) > 1)
{
$strSQL = "SELECT * FROM Members WHERE userID IN (SELECT m.userid FROM Members m, MemberSkills ms WHERE ms.userID = m.UserID AND m.MemberStatus <> 'DEL' AND ms.skill_code IN (" . $strSkills . ") AND m.postcode IN (" . $postcodeSelList . ") GROUP BY m.userid HAVING COUNT(m.userid) > 1) order by postcode, companyname ";
}
else
{
$strSQL = "SELECT m.* FROM Members m, MemberSkills ms WHERE ms.userID = m.UserID AND m.MemberStatus <> 'DEL' AND ms.skill_code IN (" . $strSkills . ") AND m.postcode IN (" . $postcodeSelList . ") order by m.postcode ";
}
}
else
{
if (count($varSkills) > 1)
{
$strSQL = "SELECT * FROM Members WHERE userID IN (SELECT m.userid FROM Members m, MemberSkills ms WHERE ms.userID = m.UserID AND m.MemberStatus <> 'DEL' AND ms.skill_code IN (" . $strSkills . ") GROUP BY m.userid HAVING COUNT(m.userid) > 1) order by postcode, companyname ";
}
else
{
$strSQL = "SELECT m.* FROM Members m, MemberSkills ms WHERE ms.userID = m.UserID AND m.MemberStatus <> 'DEL' AND ms.skill_code IN (" . $strSkills . ") order by m.postcode, companyname ";
}
}
$db = mysql_connect("localhost", "mpmsaa_plumber", "plum8e7");
if (!$db)
{
echo "Error: could not connect to the database";
exit;
}
//if we are here we have a db connection
//so select the appropriate schema
mysql_select_db("mpmsaa_plumbercom", $db);
//echo $strSQL;
mysql_select_db("plumber_com", $db);
$result = mysql_query($strSQL, $db);
if(!$result) die("Sorry, but we were unable to query the database at this time. " . mysql_error());
if (mysql_num_rows($result) <= 0)
{
echo ("Sorry, but your selection did not return any results.");
exit;
}
while($row = mysql_fetch_row($result)) {
echo "";
echo "| ";
echo $row[8];
echo " | ";
if (trim($row[9]) != "") echo $row[9] . " ";
if (trim($row[10]) != "") echo $row[10] . " ";
if (trim($row[11]) != "") echo $row[11] . " ";
if (trim($row[13]) != "") echo $row[13] . " ";
if (trim($row[14]) != "") echo $row[14] . " ";
if (trim($row[15]) != "") echo $row[15] . " ";
if (trim($row[17]) != "") echo $row[17] . " ";
if (trim($row[18]) != "") echo "" . $row[18] . "" . " ";
if (trim($row[19]) != "") echo "" . $row[19] . "" . " ";
echo " ";
echo " | ";
echo " ";
}
?>
| Find another member contractor |
|
|