我希望我的搜索专注于 URL 字符串中的变量。目前它使用基于表单的搜索。
它使用这个
<?php
include('db.php'); // include your code to connect to DB.
$tbl_name="mobile"; //your table name
$whereClauses = array();
if (! empty($_POST['Model'])) $whereClauses[] ="model='".mysql_real_escape_string($_POST['Model'])."'";
if (! empty($_POST['Mins'])) $whereClauses[] ="minutes='".mysql_real_escape_string($_POST['Mins'])."'";
if (! empty($_POST['Texts'])) $whereClauses[] ="texts='".mysql_real_escape_string($_POST['Texts'])."'";
if (! empty($_POST['Freegifts'])) $whereClauses[] ="free_gift='".mysql_real_escape_string($_POST['Freegifts'])."'";
if (! empty($_POST['Network'])) $whereClauses[] ="network_name='".mysql_real_escape_string($_POST['Network'])."'";
if (! empty($_POST['Merchant'])) $whereClauses[] ="merchant_category='".mysql_real_escape_string($_POST['Merchant'])."'";
$where = '';
if (count($whereClauses) > 0) { $where = ' WHERE '.implode(' AND ',$whereClauses); }
$sql = mysql_query("SELECT * FROM $tbl_name".$where);
?>
但是,我已将此添加到我的页面:
<?php
$model = $_GET['model']; //gets model from URL
$mins = $_GET['mins']; //gets mins from URL
$texts = $_GET['texts']; //gets mins from URL
$freegift = $_GET['free-gift']; //gets mins from URL
$network = $_GET['network']; //gets mins from URL
$plan = $_GET['plan']; //gets mins from URL
?>
它需要如此,所以并非所有变量都是必需的。任何帮助,将不胜感激。
提前致谢 :)