جستجوی پیشرفته

ithelper

Member
با سلام خدمت دوستان ... من یه کد جستجو دارم.به این صورت که نام انتخاب میشه.جدول مورد نظر هم انتخاب میشه و بعد بازه تاریخ انتخاب میشه.حالا باید جستجو کنه ... این مدل جستجو می باشد

PHP:
<form id="form1" name="form1" method="post" action="view_total_function.php">
      <table width="0" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th scope="row"><label for="edit">تدوینگر :</label>
            </th>
          <td><select name="edit" id="edit">
              <option value="#">-انتخاب کنید-</option>
            <option value="x" id="" >x</option>
            <option value="y" id="" >y</option>
            <option value="z" id="" >z</option>
            <option value="k" id="" >k</option>
          </select></td>
        </tr>
        <tr>
          <th scope="row"><label for="table">در :</label>
            </th>
          <td><select name="table" id="table">
              <option value="#">-انتخاب کنید-</option>
            <option value="tv" id="" >tv</option>
            <option value="radio" id="" >radio</option>
            <option value="menu" id="" >menu</option>
            
          </select></td>
        </tr>
        <tr>
          <th scope="row"><label for="date">از تاریخ :</label>
          </th>
          <td><div class="example"> 
            <input id="date_input_1" type="text" name="date_input_1"/><img id="date_btn_1" src="cal.png" style="vertical-align: top;" />
            <script type="text/javascript">
                Calendar.setup({
                    inputField     :    "date_input_1",   // id of the input field
                    button         :    "date_btn_1",   // trigger for the calendar (button ID)
                       ifFormat       :    "%Y-%m-%d",       // format of the input field
                       dateType       :    'jalali',
                       weekNumbers    : false
                });
            </script>
        </div></td>
        </tr>
        <tr>
        <th scope="row"><label for="date">تا تاریخ :</label></th>
        <td>
          <div class="example"> 
            <input id="date_input_2" type="text" name="date_input_2"/><img id="date_btn_1" src="cal.png" style="vertical-align: top;" />
            <script type="text/javascript">
                Calendar.setup({
                    inputField     :    "date_input_2",   // id of the input field
                    button         :    "date_btn_2",   // trigger for the calendar (button ID)
                       ifFormat       :    "%Y/%m/%d",       // format of the input field
                       dateType       :    'jalali',
                       weekNumbers    : false
                });
            </script>
        </div></td>
        </tr>
        <tr>
          <th scope="row"><input type="submit" name="btn" id="btn" value="جستجو" /></th>
          <td>&nbsp;</td>
        </tr>
      </table>
    </form>


حالا من این کد و برای خالی نبودن عریضه نوشتم و فقط برای یک حالت خاص جواب میده ... اما برای بقیه نه

PHP:
<?php
require_once "config.php";
if ($_POST['table'] = 'radio' && $_POST['edit'] = 'y')
 {
    $query = "SELECT * FROM radio WHERE date between '".$_POST['date_input_1']."' AND '".$_POST['date_input_2']."' AND edit = 'y' ";
    $result = mysql_query($query) or die ('invalid query');
    $count = mysql_num_rows($result);
                
 }
?>

میشه کمکم کنید ؟ لطفا ا ا ا ا ا ا
 

ithelper

Member
دوستان من فقط چون بازه ی زمانی دارم ... یکم گیر دارم ... لطفا کمک کنید ....
 

ithelper

Member
دوستان کد من به این شکل شد
این حالت برای تمامی رکوردها نوشتم
اما مشکلم اینجاس که رکوردی رو نشون نمیده و تعدادرو هم صفر نشون میده ...
چیکار کنم
؟؟؟؟؟؟؟؟

PHP:
$query = "SELECT * FROM `".$_POST['table']."` WHERE edit = '".$_POST['edit']."' AND date BETWEEN '".$_POST['date_input_1']."' AND '".$_POST['date_input_2']."' ";
    //echo $query;
    $result = mysql_query($query) or die ('invalid query');
    $count = mysql_num_rows($result);

                echo '<b>'.'تعداد رکوردها : '.$count.'</b>';
                echo '<br />';
 

ithelper

Member
هه درست شد ... ایراد از فرمت تاریخای دیتابیس و جستجویی بود که باهم مطابقت نداشت.
 

جدیدترین ارسال ها

بالا