EDIT: Ive adjusted my code
$rows = 0;
$connection = mysqli_connect("a", "a", "a", "a");
$rows = mysqli_query($connection, "SELECT COUNT(*) FROM chat");
for($i = 0; $i < $rows; $i++){
$result = mysqli_query($connection, "SELECT * FROM chat WHERE chat_index = 1");
$row = mysqli_fetch_all($result, MYSQLI_ASSOC);
echo "<span>".$row['name']."</span>";
echo "<img src='".$row['avatar']."'></img>";
echo "<span>".$row['flair']."</span>";
echo "<span>".$row['message']."</span>";
}
Yet nothing displays. https://CSGOVoid.net/chat
EDIT: What is the most efficient way of printing my data?
Should print (in order):
-Name
-Avatar
-Flair
-Message
I'm trying to go through every row and print the data in each column, I'm using the following:
$connection = mysqli_connect("domain", "username", "password", "mytable");
$rows = mysqli_query($connection, "SELECT COUNT(*) FROM chat");
echo $rows;
for($i = 0; $i < $rows; $i++){
$steamid = mysqli_query($connection, "SELECT steamid FROM chat WHERE chat_index = ".$i);
$name = mysqli_query($connection, "SELECT name FROM chat WHERE chat_index = ".$i);
$flair = mysqli_query($connection, "SELECT flair FROM chat WHERE chat_index = ".$i);
$avatar = mysqli_query($connection, "SELECT avatar FROM chat WHERE chat_index = ".$i);
$message = mysqli_query($connection, "SELECT message FROM chat WHERE chat_index = ".$i);
echo "<span>".$name."</span>";
echo "<img src='".$avatar."'></img>";
echo "<span>".$flair."</span>";
echo "<span>".$message."</span>";
}
I'm receiving the following error:
Catchable fatal error: Object of class mysqli_result could not be converted to string
";` let me know if that works – Webeng Apr 17 '16 at 20:56