I am trying to create a search box that searches the county field of the database. If the criteria matches then the records will be displayed in the table. I have got the different counties in the dropdown box however when I click the record the table does not change. Any help would be appreciated!

<?php
require_once("includes/session.php");
include_once("includes/masterinclude.php");

$preferences = getPreferences();
$category = "";
$attribute1 = ""; $attribute2 = ""; $attriute3 = ""; $attribute4 = "";
$top_level="0";

$name = $_GET['members'];
$information = getInformationPage($name);
$infopagename=$information->IN_NAME;
//meta data for information pages now taken from the information table
$pageTitle = $information->IN_NAME . html_entity_decode($information->IN_TITLE);
$pageMetaDescription = html_entity_decode($information->IN_META_DESC);
$pageMetaKeywords = html_entity_decode($information->IN_META_KEYWORDS);
$pageCustomHead = html_entity_decode($information->IN_CUSTOM_HEAD, ENT_QUOTES);

//initialise screen fields
$selected_member = "";
$id = "";
$username = ""; $username_original = "";
$password = ""; $password_original = "";
$password_test = "";
$title = "MR"; $first_name = ""; $last_name = ""; $company_name = "";
$address1 = ""; $address2 = ""; $town = ""; $county = ""; $country = ""; $postcode = ""; $phone = ""; $mobile = ""; $email = "";
$member_confirmed = "N";
$ast_first = 0; $ast_last = 0; $ast_company = 0; $ast_add1 = 0; $ast_add2 = 0; $ast_town = 0; $ast_county = 0; $ast_country = 0; $ast_post = 0; $ast_phone = 0;
$ast_mobile = 0; $ast_email = 0;
$ast_user = 0; $ast_pass = 0; $ast_passconf = 0;

$members = Get_All_Members("ALL");
$_GET['searchdata'] = $_POST['SEARCH_DATA']; $_GET['searchmember'] = $_POST['MEMBER'];

include_once("includes/header.php");
?>

<!-- start: Page header / Breadcrumbs -->

<div id="breadcrumbs">
    <div class="container">
        <div class="breadcrumbs"> 
        <a href="/">Home</a><i class="icon-angle-right"></i>Stockists
        </div>
    </div>
</div>

<!-- end: Page header / Breadcrumbs -->


<!-- start: Container -->
<div id="container">
    <div class="container">
        <div class="row-fluid">

        <form class="form-horizontal form-box" role="form" name="enter_thumb" action="/stockists.php" enctype="multipart/form-data" method="post" onsubmit="return validate_discount_table();"> 

        <!-- start: Page section -->
        <section class="span12">
            <div class="row-fluid shop-result">
                <div class="inner darken clearfix">
                <h1>Stockists</h1>
                </div>
            </div>



            <div class="row-fluid">

            <div class="form-group">
                    <label class="col-lg-4">Search County: </label>
                <div class="col-lg-4">
                    <Input class="form-control" name="SEARCH_DATA" type="text" size="72" value="<?php echo isset($_POST['SEARCH_DATA']) ? $_POST['SEARCH_DATA'] : "" ?>"/>
                </div>

                <div class="col-lg-4">
                    <Input name="SEARCH" type="submit" value="search" class="btn btn-primary"/>
                </div>

                <div class="col-lg-4">
                    <select name="search_results" id="jumpMenu" onchange="MM_jumpMenu('parent',this,1)">
                        <option value="#">Choose from...</option>
                            <?php
                            if (isset($_POST['SEARCH_DATA'])){
                            $members = Search_member($_POST['SEARCH_DATA']);
                            foreach($members as $m){
                            if(isset($_POST['SELECTED_MEMBER']) and $_POST['SELECTED_MEMBER'] == $m->MB_COUNTY){
                            $selected = "selected";
                            }else{
                            $selected = "";
                            }
                            echo "<option value=\"/stockists.php?searchdata=" . $_POST['SEARCH_DATA'] . "&searchmember=" . $m->MB_COUNTY . "\"" . $selected . ">" . $m->MB_COUNTY . " - " . html_entity_decode($m->MB_COUNTY) . "</option>";
                                }
                            }
                            ?>
                    </select>

                    <input type="hidden" name="SELECTED_MEMBER" value="<?php echo (isset($selected_member) ? $selected_member : "") ?>"/>
                </div>
            </div>



            <div class="form-group">
            <table class="table table-bordered table-striped table-hover">

            <thead>
            <tr>
                <th>
                   Name
                </th>
                <th>
                  Website
                </th>
                <th>
                   Phone
                </th>
                <th>
                    Address
                </th>
            </tr>
            </thead>


            <?php if($county != ""): ?>  
            <?php
                foreach($members as $m){
                    echo "<tr>";
                        echo "<td>";
                            echo "<span class=\"member_line\">" . $m->MB_COMPANY . "</span>";
                        echo "</td>";
                        echo "<td>";
                            echo "<a href=\"http://" . $m->MB_MOBILE . "\">" . $m->MB_MOBILE . "</a>";
                        echo "</td>";
                        echo "<td>";
                            echo "<span class=\"member_line\">" . $m->MB_PHONE . "</span>";
                        echo "</td>";
        //              echo "<td>";
        //                  echo "<a href=\"mailto:" . $m->MB_EMAIL . "\"><span style=\"color:#669999;\" class=\"member_line\">" . $m->MB_EMAIL . "</span></a>";
        //              echo "</td>";-->
                        echo "<td>";
                            echo "<span class=\"member_line\">" . $m->MB_ADDRESS1 . ", " . $m->MB_ADDRESS2 . ", " . $m->MB_TOWN . ", " . $m->MB_COUNTY . ", " . $m->MB_POSTCODE . "</span>";
                        echo "</td>";
                    echo "</tr>";
                }
                echo "</table>"; 
             ?>
             </table>

             <?php endif; ?>

             </div>
            </div>
            </form>  
        </section>
        <!-- end: Page section -->


        </div>

    </div>
</div>
<!-- end: Container -->



<?php
  include_once("includes/footer.php");
?>

Recommended Answers

All 3 Replies

when I click the record the table does not change

What exactly do you mean by this? Describe what you expect to happen, but what isn't working.

I have done this however when I run the query it displayss an error

SQL query: Documentation

SELECT *
FROM memberif( isset(
$_POST[ 'search']
) ) {$search_term = mysql_real_escape_string(
$_POST[ 'search_box']
);

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if (isset($_POST['search'])) {

                $search_term = mysql_real_escape_strin' at line 3
Member Avatar for diafol

This post is exactly the same as the one you posted in another thread. Any reason for this?

commented: noticed that too +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.