Advertisement
Guest User

rahim/from

a guest
Aug 29th, 2015
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <?php
  2. include("include/include.php");
  3. $country="0";
  4. if(isset($_REQUEST['country']))
  5. {
  6. $country=$_REQUEST['country'];
  7. }
  8. ?>
  9.  
  10. <a href="cityfrom.php">New Entry</a><hr/><br/>
  11. <form method="post">
  12. <fieldset>
  13. <legend>Search</legend>
  14. <select name="country">
  15. echo '<option value="0">Select</option>';
  16. <?php
  17. $sql="select *from country where id in(select countryid from city)";
  18. $r = mysql_query($sql);
  19. while ($row = mysql_fetch_row($r))
  20. {
  21. if($country ==$row[0])
  22. {
  23. echo '<option value="'.$row[0].'"Selected>'.$row[1].'</option>';
  24. }
  25. else{
  26. echo '<option value="'.$row[0].'">'.$row[1].'</option>';
  27. }
  28.  
  29. }
  30. ?>
  31. </select><input type="submit" name="submit" value="Search">
  32. </fieldset>
  33. </form>
  34. <?php
  35. $sql="select ci.id,ci.name,c.name from city as ci,country as c where ci.countryid=c.id";
  36. if($country > 0)
  37. {
  38. $sql .= "and country.id=" .$country;
  39. }
  40. $result = mysql_query($sql);
  41. echo '<table>';
  42. echo '<tr><th>Name</th><th>Country</th></tr>';
  43. while ($row = mysql_fetch_row($result))
  44. {
  45. echo '<tr>';
  46. echo '<td>'.$row[1].'</td>';
  47. echo '<td>'.$row[2].'</td>';
  48. echo '</tr>';
  49. }
  50. echo '</table>';
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement