How to generate ids for tables made by php

I am trying to create a page to allow toggling on and off certain forums in website, created from raw data in an SQL server. However I need each to have an individual ID so I can show/hide them based on user preference. I am not sure how to go about it. Here is my existing code, disregard the connection values, I am hiding them on purpose. thanks.

$db_host = "host";
$db_username = "username";
$db_pass = "pass";
$db_name = "name";
$db = new PDO('mysql:host='.$db_host.';dbname='.$db_name,$db_username,$db_pass);
$query = $db->query('SELECT,, o.prodtype AS Type
FROM ownedproducts AS o
JOIN product as p ON p.productID = o.productID
WHERE o.usersID = 2');
<link rel="stylesheet" type="text/css" href="style.css" />
<title> User Forum Selection </title>
<input type="text" id="userid">
<table id=table border = '2'>
<tr id=table-row>
<th id=table-header>Name</th>
<th id=table-header>Company</th>
<th id=table-header>Type</th>
while ($row = $query->fetch()) 
    echo "<tr id=table-row >";
    echo "<td>" . $row['name'] ."</td>";
    echo "<td>" . $row['company'] . "</td>";
    echo "<td>" . $row['Type'] . "</td>";
    echo "</tr>";


Read more here:

Content Attribution

This content was originally published by JewGiOh at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: