Hi all, I'm obviously new to PHP. Have done a bit of ASP VBScript in the past but php is seeming very foreign to me.
What I'm trying to do is display a dynamic table that contains statistical information. About the various assets and the number of them contained within the database table.
My MySQL DB contains a table called Assets. I'm trying to display data from a single column called AssetType.
I would like to display the AssetType name such as "Laptop" once with the total number of laptops next to it.
I can manually do:
echo "Laptops : <b>$number</b>
I attain the result I want, however If someone were to add a new AssetType such as "Desktop" to the table I don't want to have to manually go back and add:
echo "Desktops : <b>$number</b>
I don't know how to build the code to fill in that asset type dynamically. Basically what I'm picturing in my head would be something like this:
echo "$AssetType : <b>$number</b>
I have no idea how to do this. I've been Googling for a few hours and I'm beginning to think I don't know how to phrase what I'm searching for.
I have the following as my SQL query
$query = mysql_query("SELECT AssetType FROM Assets WHERE Retired IS NULL");
$number=mysql_num_rows($query);
I think there needs to be something in between $query and $number but I'm clueless. Any help at all and I will bow to you as lord of PHP.