Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2. $servername = ""; $username = ""; $password = ""; $dbname = "";
  3. $conn = mysqli_connect($servername, $username, $password, $dbname);
  4. if (!$conn) {
  5. die("Connection failed: " . mysqli_connect_error());}
  6. $sql_1 = "SELECT id, title, main_image FROM posts WHERE $sql_2 = 'category_title' AND $sql_3 ='country_iso_code'";
  7. $sql_2 = "SELECT id, post_id, category_title FROM post_categories";
  8. $sql_3 = "SELECT id, post_id, country_iso_code FROM post_countries";
  9. $category_title =$_REQUEST['category'];
  10. $country_iso_code =$_REQUEST['country'];
  11. $result = mysqli_query($conn, $sql_1);
  12. if (mysqli_num_rows($result) > 0) {
  13. // output data of each row
  14. while($row = mysqli_fetch_assoc($result)) {
  15. echo "id: " . $row["id"]. " - Title: " . $row["title"]. " " . $row["main_image"]. "<br>";
  16. }
  17. } else {
  18. echo "0 results";
  19. }
  20.  
  21. mysqli_close($conn);
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement