Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <?php
  2. $html = '<div id="one">
  3. <select id="first">
  4. </select>
  5. </div>
  6. <div id="two">
  7. <select id="second">
  8. </select>
  9. </div>';
  10. $dom = new DOMDocument();
  11. $dom->validateOnParse = true;
  12. $dom->loadHTML($html);
  13. $result_one = get_model();
  14. $string = "audi BMW BMW Ford Ford Ford Ford Ford A6 'A5' mokka mokka.";
  15. if($result_one == true){
  16. while($row = mysqli_fetch_array($result_one)){
  17. $pattern = "/b" . $row["name_model"] . "b/i";
  18. if (preg_match_all($pattern, $string, $matches)){
  19. for ($i=0; $i < count($matches[0]); $i++){
  20. $count = count($matches[0]);
  21. $result = $matches[0][$i];
  22. $result_id = $row["brand_id"];
  23. }//echo $count;
  24.  
  25. $item = $dom->getElementById('first');
  26. $opt = $item->appendChild($dom->createElement("option", $result));
  27.  
  28. $query = "SELECT * ";
  29. $query .= "FROM brands ";
  30. $query .= "WHERE brand_id = $result_id ";
  31. $result_match = mysqli_query($link, $query);
  32.  
  33. $result_two = $result_match;
  34. var_dump($result_two);
  35. if($result_two == true) {
  36. while($row = mysqli_fetch_array($result_two)){
  37. $res = $row["brand_name"];
  38.  
  39. $item_2 = $dom->getElementById('second');
  40. $opt = $item_2->appendChild($dom->createElement("option", $res));
  41. }
  42.  
  43. }
  44. }
  45.  
  46. }
  47.  
  48.  
  49. }
  50. echo $dom->saveHTML();
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement