This is complete template Example for custom table query search.
<?php
/**
* Template Name: Advanced Search Result Page
*/
?>
<?php get_header(); ?>
<div class="main_content">
<div class="page_content_wrapper">
<div class="page_content the_content">
<div class="ad-search">
<form role="search" method="get" action="/advanced-serach-result">
Advanced Search <input type="text" value="" name="adsearch" />
<input type="submit" value="Advanced Search" name="submit" />
</form>
</div>
<?php
if(isset($_GET['submit'])){
if(preg_match("/^[a-zA-Z 0-9]+/", $_GET['adsearch'])){
$term = $_GET['adsearch'];
$admin = admin_url();
$url = plugins_url();
$sql="SELECT * FROM wp_usersinfo WHERE name LIKE '%" . $term . "%' OR city LIKE '%" . $term ."%' OR race LIKE '%" . $term ."%' OR state LIKE '%" . $term ."%' OR hometown LIKE '%" . $term ."%' OR crime LIKE '%" . $term ."%' OR eyes LIKE '%" . $term ."%' OR hair LIKE '%" . $term ."%' OR height LIKE '%" . $term ."%' OR weight LIKE '%" . $term ."%' OR gender LIKE '%" . $term ."%'";
$result = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($result);
echo "Total Inmates Found : - $num_rows \n";
while($row = mysql_fetch_array($result)){
$ID = $row['id'];
echo "<ul class='ad-right-detail'>\n";
echo "<li><span><strong>" . "<a href=\"my-detail-page?id=$ID\">" .$row['name'] ."</a></span></strong></li>\n";
echo "</ul>";
}
}
}
?>
</div>
</div>
</div>
<?php get_footer(); ?>
<?php
/**
* Template Name: Advanced Search Result Page
*/
?>
<?php get_header(); ?>
<div class="main_content">
<div class="page_content_wrapper">
<div class="page_content the_content">
<div class="ad-search">
<form role="search" method="get" action="/advanced-serach-result">
Advanced Search <input type="text" value="" name="adsearch" />
<input type="submit" value="Advanced Search" name="submit" />
</form>
</div>
<?php
if(isset($_GET['submit'])){
if(preg_match("/^[a-zA-Z 0-9]+/", $_GET['adsearch'])){
$term = $_GET['adsearch'];
$admin = admin_url();
$url = plugins_url();
$sql="SELECT * FROM wp_usersinfo WHERE name LIKE '%" . $term . "%' OR city LIKE '%" . $term ."%' OR race LIKE '%" . $term ."%' OR state LIKE '%" . $term ."%' OR hometown LIKE '%" . $term ."%' OR crime LIKE '%" . $term ."%' OR eyes LIKE '%" . $term ."%' OR hair LIKE '%" . $term ."%' OR height LIKE '%" . $term ."%' OR weight LIKE '%" . $term ."%' OR gender LIKE '%" . $term ."%'";
$result = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($result);
echo "Total Inmates Found : - $num_rows \n";
while($row = mysql_fetch_array($result)){
$ID = $row['id'];
echo "<ul class='ad-right-detail'>\n";
echo "<li><span><strong>" . "<a href=\"my-detail-page?id=$ID\">" .$row['name'] ."</a></span></strong></li>\n";
echo "</ul>";
}
}
}
?>
</div>
</div>
</div>
<?php get_footer(); ?>
No comments:
Post a Comment