I need to be able to compare values from a column, not the number of times a value appears in the columns. I have multiples tables that all have the same 20 column 'title' entries, but another column 'position_order' are different values of numbers. I have a base table with the 'correct' values, and I want to go through each name in the column 'title' and calculate the difference between their 'position_order' and my base case table's 'position_order'
I believe I have it all working but when I query the database to find what value it has stored for the column 'position_order' for some reason it won't return as a number that I can do calculations on.
<?php
echo "
<h3 class='text-center'>Table Name</h3>
<table class='table table-bordered'>
<tr>
<th>#</th>
<th>Title</th>
<th>Score</th>
</tr>
<tbody class='row_position'>"?>
<?php
require('db_config.php');
$tablename = $_SESSION['username'] . "_laliga";
$_SESSION['tablename'] = $tablename;
$sql = "SELECT * FROM $tablename ORDER BY position_order";
$users = $mysqli->query($sql);
while($user = $users->fetch_assoc()){
$sql1 = "SELECT `position_order` FROM '".$tablename."' WHERE `title` LIKE '".$user['title']."' ";
$sql2 = "SELECT `position_order` FROM `laliga` WHERE `title` LIKE '".$user['title']."' ";
$position1 = $mysqli->query($sql1);
$position2 = $mysqli->query($sql2);
?>
<tr id="<?php echo $user['id'] ?>">
<td><?php echo $user['position_order'] ?></td>
<td><?php echo $user['title'] ?></td>
<td><?php echo abs($position1-$position2); ?></td>
</tr>
<?php } ?>
</tbody>
</table>
Here is the error log
[16-May-2019 22:19:48 UTC] PHP Notice: Object of class mysqli_result could not be converted to number in /Applications/MAMP/htdocs/user.php on line 75