Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("include/include.php");
- $country="0";
- if(isset($_REQUEST['country']))
- {
- $country=$_REQUEST['country'];
- }
- ?>
- <a href="cityfrom.php">New Entry</a><hr/><br/>
- <form method="post">
- <fieldset>
- <legend>Search</legend>
- <select name="country">
- echo '<option value="0">Select</option>';
- <?php
- $sql="select *from country where id in(select countryid from city)";
- $r = mysql_query($sql);
- while ($row = mysql_fetch_row($r))
- {
- if($country ==$row[0])
- {
- echo '<option value="'.$row[0].'"Selected>'.$row[1].'</option>';
- }
- else{
- echo '<option value="'.$row[0].'">'.$row[1].'</option>';
- }
- }
- ?>
- </select><input type="submit" name="submit" value="Search">
- </fieldset>
- </form>
- <?php
- $sql="select ci.id,ci.name,c.name from city as ci,country as c where ci.countryid=c.id";
- if($country > 0)
- {
- $sql .= "and country.id=" .$country;
- }
- $result = mysql_query($sql);
- echo '<table>';
- echo '<tr><th>Name</th><th>Country</th></tr>';
- while ($row = mysql_fetch_row($result))
- {
- echo '<tr>';
- echo '<td>'.$row[1].'</td>';
- echo '<td>'.$row[2].'</td>';
- echo '</tr>';
- }
- echo '</table>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement