Guest User

Untitled

a guest
May 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. table_1
  2. +----------+-----------+--------------+
  3. | category | Spec_Name | Spec_Value |
  4. +----------+-----------+--------------+
  5. | Engine | x | 111111111111 |
  6. +----------+-----------+--------------+
  7. | Engine | y | 222222222222 |
  8. +----------+-----------+--------------+
  9.  
  10. table_2
  11. +----------+-----------+--------------+
  12. | category | Spec_Name | Spec_Value |
  13. +----------+-----------+--------------+
  14. | Engine | x | 111111111111 |
  15. +----------+-----------+--------------+
  16.  
  17. So, the Spec_Name.y wouldn't exist in table_2.
  18.  
  19.  
  20. In that case, I'd like to show this for a user:
  21.  
  22. +---------+----------------+----------------+
  23. |Spec_Name| car1.Spec_Value|car2.Spec_Value |
  24. +---------+----------------+----------------+
  25. | x | 111111111111 | - |
  26. | y | - | 55555565 |
  27. | z | 333333333333 | 77777777 |
  28. etc.
  29.  
  30. function printCarData($conn, $table){
  31. $query = "SELECT Spec_Name, Spec_Value, SUBSTRING(Spec_Value, 1, 20), TechSpecCategoryName FROM ".$table;
  32. if($result = mysqli_query($conn, $query)){
  33. echo"<ul>";
  34. while($row = mysqli_fetch_assoc($result)){
  35.  
  36. if($query != $row["TechSpecCategoryName"]){
  37.  
  38. echo "<li>"."<br>"."</li>";
  39. }
  40. echo "<li>".$row["SUBSTRING(Spec_Value, 1, 20)"]."</li>";
  41.  
  42. $query = $row["TechSpecCategoryName"];
  43. }
  44. echo"</ul>";
  45. }
  46. }
  47.  
  48. printCarData($link, $table_name)
Add Comment
Please, Sign In to add comment