Jump to content

mattix

Members
  • Posts

    30
  • Joined

Everything posted by mattix

  1. Thank you, Barand. This is all new. I'll work on this.
  2. This is the data on the table. id, grpa, grpb 1, 1, 5 2, 4, 6 3, 8, 9 4, 3, 3 5, 5, 4 6, 7, 8 7, 9, 10 8, 10, 5 9, 10, 9 and this the desired table from the original table. I showed the expected table in horizontal view to prevent confusion. My real table is vertical in the code.
  3. I tried this before, it lists all category keys in the html table. It's supposed to list only the category key numbers that matches the value, if not the output to be blank.
  4. yes, this doesn't give error. but it doesn't list the category keys, it lists category values. any ideas there too? if not, thanks anyway.
  5. true. thanks. but even though i made the change you proposed, i still get the same error.
  6. How can I get rid of "Notice:Array to string conversion on line 78" error from this code? can i get a little help please? This is line 78 : $table .= $columnValue; Basically this code's supposed to do is to group the values from grpa, grpb of datatb to 4 different categories according to their value. and as end result, category index number of each category is put into the html table. Thanks. <?php include ("configd.php"); $sql = "SELECT grpa, grpb From datatb"; $result = $conn->query($sql); //categories $cat = [ 4 => [1, 2, 3, 4], 3 => [5, 6], 2 => [7, 8], 1 => [9, 10] ]; while ($row = $result->fetch_assoc()) { foreach ($cat as $catKey => $catValue) { $columns[$catKey] = array_filter($row, function ($col) use ($cat, $catKey) { if (in_array($col, $cat[$catKey])) { return true; } }); } $output[] = $columns; } // the output $table = <<<EOT <table class='maintable'> <tr><th>9:10</th></tr> <tr><th>7:8</th></tr> <tr><th>5:6</th></tr> <tr><th>1:4</th></tr> </table> EOT; foreach ($output as $row) { $table .= "<table class='maintable'>"; foreach ($row as $columnKey => $columnValue) { $table .= "<tr>"; $table .= "<td>"; $table .= $columnValue; $table .= "</td>"; } $table .= "</tr>"; $table .= "</table>"; } echo $table; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.