I created a function to show my data from the mysql database into a simple table and it works fine. The only problem is that I need to filter out the results which have value 1 for the "bot" column and show all the other rows. (The value is only 1 when the useragent shows its a bot).
It sort of seems to work but instead of no showing the whole row it just changes every single value in the "bot" column to a 0.
if(isset($_POST['togglebots'])){
$sqlselect = "SELECT * FROM `page_load` WHERE `bot` = 0";
}else{
$sqlselect = "SELECT * FROM page_load";
}
So when the checkbox is enabled it will only who the rows which have a value of 0 for the "bot" column. Or atleast thats what it is supposed to do, instead it changes all the values to a 0 and shows everything anyway lol
The code I use to generate the table is this:
if ($resultselect->num_rows > 0) {
echo '<div style="margin:10px;"><table style="padding:10px">';
while($row = mysqli_fetch_array($resultselect, MYSQLI_BOTH)) {
$temp = date('Y-m-d h:i:s',$row['firsttime']);
$temp2 = date('Y-m-d h:i:s',$row['lasttime']);
echo '
<tr >
<td style="padding:6px; border: 1px solid black;">ID: </td>
<td style="padding:6px; border: 1px solid black;"> ' . $row['id'] . ' </td>
<td style="padding:6px; border: 1px solid black;">Useragent:</td>
<td style="padding:6px; border: 1px solid black;"> ' . $row['useragent'] . ' </td>
<td style="padding:6px; border: 1px solid black;">REMOTE ADDR:</td>
<td style="padding:6px; border: 1px solid black;"> ' . $row['ip_address'] . ' </td>
<td style="padding:6px; border: 1px solid black;">TAG: </td>
<td style="padding:6px; border: 1px solid black;">' . $row['tag'] . ' </td>
<td style="padding:6px; border: 1px solid black;">BOT: </td>
<td style="padding:6px; border: 1px solid black;">' . $row['bot'] . ' </td>
<td style="padding:6px; border: 1px solid black;">First reload: </td>
<td style="padding:6px; border: 1px solid black;">' . $temp . ' </td>
<td style="padding:6px; border: 1px solid black;">Last reload: </td>
<td style="padding:6px; border: 1px solid black;">' . $temp2 . '</td>
<td style="padding:6px; border: 1px solid black;">Total reloads: </td>
<td style="padding:6px; border: 1px solid black;">' . $row['totalreloads'] . '</td>
</tr>';
}
echo '</table></div>';
} else {
echo "<p>0 results</p></table></div>";
}
It runs through all the results and adds the values to a new row in the table. If there are no results it simple outputs "0 results".
EDIT: full page source code