0

Help me

I code chat room i want to put my message write and oders left I use if loop but not work heres a code <?php require("con.php"); $result = $con->query("SELECT * FROM chat ORDER BY id ASC"); foreach($result as $row){ if($_SESSION['user'] == $row['user']){ echo "<div style='width:100vw; text-align:right;'><div style='display:inline;color:red; background:#444;margin-bottom:10px;width:auto;border-radius:10px; padding:5px; text-align:center;'>".$row['user']. ": " ."<span style='color:white;'>".$row['msg']."</span></div>"."</div><br>"; }else{ echo "<div><div style='display:inline;color:blue; background:#444;margin-bottom:10px;width:auto;border-radius:10px; padding:5px; text-align:center;'>".$row['user']. ": " ."<span style='color:white;'>".$row['msg']."</span></div>"."</div><br>"; } } ?>

24th Mar 2020, 2:34 PM
Mohammad
Mohammad - avatar
1 Answer
+ 1
Can you describe the problem with more details? "not work" doesn't describe the problem specifically. I suggest to prefer use of embedded style on the page instead of inline style for each <div>. Easier to edit the style and less crowded in output with embedded style. Please save the code in SoloLearn, then share the link in your thread Description rather than raw text. It's easier for others to check and analyze 👍
29th Mar 2020, 7:32 AM
Ipang