/    Sign up×
Community /Pin to ProfileBookmark

PHP Advanced Search

I am in the process of trying to fix this code. Whoever created it, disabled the advanced feature of my friends site. I am new to PHP and would appreciate any advice/help anyone can offer.

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYDec 08.2005 — could you please place your code in vB tags ?
Copy linkTweet thisAlerts:
@ddeleonauthorDec 08.2005 — You will probably think that this is really stupid, but how do I place them in vB tags?
Copy linkTweet thisAlerts:
@ShrineDesignsDec 08.2005 — example (w/o spaces)[ php ]code here[ /php ]
Copy linkTweet thisAlerts:
@FromU2MEDec 08.2005 — If you want advanced search, you'll need to write the code yourself (apparently):

[code=php]if ($_GET[search_by] == "advanced_search")
{
$search_result = "Advance search is not available at this time, please try again later.";
}[/code]
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYDec 08.2005 — nope, not stupid at all! i mean who in the world(new to a vB[ulltin] forum) knows what vB tags are!Sorry

So they are either available from the advanced panel or manually

for php-vB tags enter [B][ php ][/B] [I]your code here[/I] [B][/ php ][/B] (without the spaces!)

which would color the code and indent it so it's much more readable for us

for code tags: [B][ code ][/B] [I]your code here[/I] [B][/ code ][/B]

thanks
Copy linkTweet thisAlerts:
@FromU2MEDec 08.2005 — LiLcRaZyFuZzY - I agree!
Copy linkTweet thisAlerts:
@ddeleonauthorDec 09.2005 — [code=php] <div align="center"><?php <div align="center"><?php
include("admin/connection.php");
if($_GET[search_by] == "plan_nametype")
{

$sql = "SELECT * FROM $db_table WHERE plan_name LIKE '$_POST[plan_name]'";
$result = @mysql_query($sql, $link) or die (mysql_error());


$num_rows = mysql_num_rows($result);

if($num_rows == 0){
$search_result = "We didn't find any house plan with the name of $_POST[plan_name], but here are some house plans in the $_POST[plan_type] category.";
$sql2 = "SELECT * FROM $db_table WHERE att_foyer LIKE '$_POST[plan_type]'";
$result2 = @mysql_query($sql2, $link) or die (mysql_error());

$num_rows = mysql_num_rows($result2);
if($num_rows == 0){
$search_result = "We didn't find any house plan with the name of $_POST[plan_name], and there are no house plans in the $_POST[plan_type] category.";
}

while($row = @mysql_fetch_array($result2)){
$plan_number = $row[plan_number];
$plan_name = $row[plan_name];
$att_plan_type = $row[att_plan_type];
$img_photo = $row[img_photo];
$img_elevation = $row[img_elevation];

if($img_photo == ""){
$plan_thumb = $img_elevation;
}
else
{
$plan_thumb = $img_photo;
}


$display_results_box .= "<table width=700 height=97 border=0 align=center cellpadding=0 cellspacing=0>
<tr>
<td width=150 height=98 rowspan=4><div align=center><img src="plan_house_images/$plan_number/thumbs/$plan_thumb"></div></td>
<td width=109>Plan Name: </td>
<td width=441>$plan_name</td>
</tr>
<tr>
<td> Plan Number: </td>
<td>$plan_number</td>
</tr>
<tr>
<td> Plan Type:</td>
<td>$att_plan_type</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan=3><hr></td>
</tr>
</table>";

}

}
else
{
while($row = mysql_fetch_array($result)){

$plan_number = $row[plan_number];
$plan_name = $row[plan_name];
$att_plan_type = $row[att_plan_type];

//Square Footage
$sf_total = $row[sf_total];
$sf_first_floor = $row[sf_first_floor];
$sf_second_floor= $row[sf_second_floor];
$sf_garage = $row[sf_garage];
$sf_basement = $row[sf_basement];
$img_photo = $row[img_photo];
$img_elevation = $row[img_elevation];

if($img_photo == ""){
$plan_thumb = $img_elevation;
}else{
$plan_thumb = $img_photo;
}

if($att_plan_type != $_POST[plan_type]){
$search_result = "We found $num_rows house plan(s) in our database, but it doesn't match the $_POST[plan_type] category ";
}
else
{
$search_result = "We found $num_rows house plan(s) in our database.";
}

$display_results_box = "<table width=700 height=97 border=0 align=center cellpadding=0 cellspacing=0>
<tr>
<td width=150 height=98 rowspan=4><div align=center><img src="plan_house_images/$plan_number/thumbs/$plan_thumb"></div></td>
<td width=109>Plan Name: </td>
<td width=441>$plan_name</td>
</tr>
<tr>
<td> Plan Number: </td>
<td>$plan_number</td>
</tr>
<tr>
<td> Plan Type:</td>
<td>$att_plan_type</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan=3><hr></td>
</tr>
</table>";
}
}
}

if($_GET[search_by] == "advanced_search")
{
$search_result = "Advance search is not available at this time, please try again later.";
}
?>
</div>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="144" class="style18"><strong>Search Result: </strong></td>
<td width="606" class="style18"><strong><?php echo "$search_result"; ?></strong></td>
</tr>
<tr>
<td colspan="2"><?php echo "$search_result_different"; ?>&nbsp;</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2"><div align="center"><?php echo "$display_results_box";?></div></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</table></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>[/code]
Copy linkTweet thisAlerts:
@ddeleonauthorDec 09.2005 — I think that I got it this time. So the query is not actually there, right? Can anyone help with that?
×

Success!

Help @ddeleon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...