Adding a drop down select field
I decided to play around with the free verion of indexu before buying the real thing just to make sure it would do what I needed.
So here is a hack to the power search routine of the lite version ( May 2002 ) to add the ability to find or include those links that are editor picks. I just wanted to see how easy it was. and it was pretty easy. Especially, since my knowledge of PHP is limited to how to spell it and my knowledge of mySQL is only a tad more.
Anyway, here it is.
change
global $cat,$title,$url,$category,$description, $contact_name, $email;
to
global $cat,$title,$url,$category,$description, $contact_name, $email
, $pick;
underneath the line above, add:
$pick= ShowDropDown ("pick","---,Yes,No","2,1,0","");
Notes:
$pick is the name of the variable in this function as declared in the global variables
pick is the name of the form variable in the html page
"---,Yes,No" are the possible choices as shown to the user when viewing the html page
"2,1,0" are the actual values to be passed to the database.
the final "" is the default value of the select statement as presented to the user viewing the html page. By using a "1" the pick box would default to "Yes" when viewed by the user. A zero ( 0 ) would cause the select statement to default to No and "2" would cause it to default to "---". Actually, I believe anything that did not match any of the choices would cause it to default to "---".
You will need to change
DisplayTemplate($template_path."power_search_form. html",
"\$error_msg,\$title,\$url,\$category,\$descriptio n,\$contact_name,\$email");
to the following
DisplayTemplate($template_path."power_search_form. html",
"\$error_msg,\$title,\$url,\$category,\$descriptio n,\$contact_name,\$email
, \$pick");
somewhere under
$query = "select * from link where 0=0 ";
add
if($pick==1) {
$query .= "and f_pick = 1 ";
}
elseif ($pick==0) {$query .= "and f_pick = 0 ";}
Note: I don't think there is a real need to test for $pick==2 since that means f_pick is not to be part of the query.
Finally, in the power_search_form.html file add
<tr>
<td><font face="Arial" size="2">Pick</font></td>
<td><%pick%></td>
</tr>
after the row for the email row and before the submit button.
Sorry about the above quote but vBulletin wants to recogize the row and cell tags.
Last edited by esm; 05-22-2003 at 01:02 PM.
esm
"The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."
.