| Member with 1,002 posts. THREAD STARTER | | Join Date: Dec 2011 Location: Johannesburg South Africa Experience: Intermediate | |
Connect... PHP Code: function OpenDB()
{
global $result;
$con = mysql_connect("localhost","surfwhee_jim","********************") or die(mysql_error());
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("surfwhee_vehicles", $con) or die(mysql_error());
}
(Password obscured)
This is the CMS compatible php code... PHP Code: else if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "do_search")
{
OpenDB();
$element = $_REQUEST["element"];
$criteria = trim($_REQUEST["criteria"]);
$row = mysql_query("SELECT * FROM vehicles WHERE $element LIKE $criteria ORDER BY id") or die(mysql_error());
BB_RedirectPage("success", "Search Results for " . $criteria . " in " . $element, array("action=managevehicles&sec_t=" . BB_CreateSecurityToken("managevehicles") . "&order=" . $order));
}
else if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "search")
{
$criteria = "";
$element = "";
$contentopts = array(
"desc" => "Search the Database for specific criteria.",
"nonce" => "action",
"hidden" => array(
"action" => "do_search",
),
"fields" => array(
"startrow",
array(
"title" => "Search in...",
"type" => "select",
"name" => "element",
"options" => array("datetime" => "Date", "fullname" => "Name", "make" => "Make", "year" => "Year", "model" => "Model",),
"width" => "150px",
"value" => BB_GetValue("element", $element),
"desc" => ""
),
array(
"title" => "Search for...",
"type" => "text",
"name" => "criteria",
"width" => "200px",
"value" => BB_GetValue("criteria", $criteria),
"desc" => ""
),
),
"submit" => "Go",
"focus" => true
);
BB_GeneratePage("Search For", $menuopts, $contentopts);
}
|