search example on selection wise search

search example on selection wise search - Hallo sahabat Tutorials, Pada Artikel yang anda baca kali ini dengan judul search example on selection wise search, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.

Judul : search example on selection wise search
link : search example on selection wise search

Baca juga


search example on selection wise search

How to write code  for following example  suppose
(1) if 
You   select  city Mumbai then it will display only city Mumbai record
(2)if you select country   India  then it will display only  country  India record
(3)if you select both city=Mumbai and country=India  then it will  record where Mumbai and India is matched..together..

(1)create table details :
create  table  details
(id   int    primary   key   auto_increment ,
 city  varchar(20),
 country  varchar(20)
 );
(2)write code for  search.php file given below :

<form action=search.php method=post>
                City        :<input type=text name=city>
                Country                :<input type=text name=country>
                <input type=submit name=submit value=Filter>
</form>
<?php
if(isset($_POST['submit']))
{
                $city=$_POST['city'];
                $country=$_POST['country'];
                $con=mysql_connect('localhost','root','');
                mysql_select_db('abhi',$con);
                if($_POST['city']==true && $_POST['country']==false)
                {
                                $sql="select * from details where city='$city'";
                                $result=mysql_query($sql);
                                echo '<table border=5><tr><td>Id</td><td>City</td><td>Country</td></tr>';
                                while($row=mysql_fetch_array($result))
                                {
                                                echo '<tr>';
                                                                echo '<td>';
                                                                                echo $row['id'];
                                                                echo '</td>';
                                                                echo '<td>';
                                                                                echo $row['city'];
                                                                echo '</td>';
                                                                echo '<td>';
                                                                                echo $row['country'];
                                                                echo '</td>';
                                                echo '</tr>';
                                }
                                echo '</table>';
                }
               
                else if($_POST['city']==false && $_POST['country']==true)
                {
                                $sql="select * from details where country='$country'";
                                $result=mysql_query($sql);
                                echo '<table border=5><tr><td>Id</td><td>City</td><td>Country</td></tr>';
                                while($row=mysql_fetch_array($result))
                                {
                                                echo '<tr>';
                                                                echo '<td>';
                                                                                echo $row['id'];
                                                                echo '</td>';
                                                                echo '<td>';
                                                                                echo $row['city'];
                                                                echo '</td>';
                                                                echo '<td>';
                                                                                echo $row['country'];
                                                                echo '</td>';
                                                echo '</tr>';
                                }
                                echo '</table>';
                }
                else if($_POST['city']==true && $_POST['country']==true)
                {
                                $sql="select * from details where city='$city' and country='$country'";
                                $result=mysql_query($sql);
                                echo '<table border=5><tr><td>Id</td><td>City</td><td>Country</td></tr>';
                                while($row=mysql_fetch_array($result))
                                {
                                                echo '<tr>';
                                                                echo '<td>';
                                                                                echo $row['id'];
                                                                echo '</td>';
                                                                echo '<td>';
                                                                                echo $row['city'];
                                                                echo '</td>';
                                                                echo '<td>';
                                                                                echo $row['country'];
                                                                echo '</td>';
                                                echo '</tr>';
                                }
                                echo '</table>';
                }
                else
                {
                                echo "No record";
                }
                }

?>


Demikianlah Artikel search example on selection wise search

Sekianlah artikel search example on selection wise search kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.

Anda sekarang membaca artikel search example on selection wise search dengan alamat link https://othereffect.blogspot.com/2016/03/search-example-on-selection-wise-search.html

0 Response to "search example on selection wise search"

Post a Comment