Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- table_1
- +----------+-----------+--------------+
- | category | Spec_Name | Spec_Value |
- +----------+-----------+--------------+
- | Engine | x | 111111111111 |
- +----------+-----------+--------------+
- | Engine | y | 222222222222 |
- +----------+-----------+--------------+
- table_2
- +----------+-----------+--------------+
- | category | Spec_Name | Spec_Value |
- +----------+-----------+--------------+
- | Engine | x | 111111111111 |
- +----------+-----------+--------------+
- So, the Spec_Name.y wouldn't exist in table_2.
- In that case, I'd like to show this for a user:
- +---------+----------------+----------------+
- |Spec_Name| car1.Spec_Value|car2.Spec_Value |
- +---------+----------------+----------------+
- | x | 111111111111 | - |
- | y | - | 55555565 |
- | z | 333333333333 | 77777777 |
- etc.
- function printCarData($conn, $table){
- $query = "SELECT Spec_Name, Spec_Value, SUBSTRING(Spec_Value, 1, 20), TechSpecCategoryName FROM ".$table;
- if($result = mysqli_query($conn, $query)){
- echo"<ul>";
- while($row = mysqli_fetch_assoc($result)){
- if($query != $row["TechSpecCategoryName"]){
- echo "<li>"."<br>"."</li>";
- }
- echo "<li>".$row["SUBSTRING(Spec_Value, 1, 20)"]."</li>";
- $query = $row["TechSpecCategoryName"];
- }
- echo"</ul>";
- }
- }
- printCarData($link, $table_name)
Add Comment
Please, Sign In to add comment