What is the "standard practice" for grouping multiple returns of the "same item" in a simple join query?
Please observe this lines from a working MySQL query Method:
$AGquery = "SELECT cat_id_ag, ag_id, ag_identity, ag_nickname, ag_details
FROM aguitar_inventory, aguitar_models
WHERE aguitar_inventory.ag_id = aguitar_models.ag_identity";
$AGresult = mysql_query($AGquery,$dblink) or die("I could not connect to the database because ".mysql_error());
$this->many=mysql_num_rows($AGresult);
for($z=0;$z<$this->many;$z++) {
$counter[$z]= mysql_fetch_array($AGresult, MYSQL_ASSOC);
}
It's technically giving me what i'm asking for, but i don't want it to show all that it does in the ultimate "end-user view". Allow me to elaborate just a bit as it will probably cut-to-the-chase a bit faster: it's an on-line inventory for my friend's guitar store. I want the results to show one-of-each item
currently, any duplicate inventory item is printed as part of the $counter array...
...resulting in an output like:
$counter[0] = guitarA,
$counter[1] = guitarA,
$counter[3] = guitarA,
$counter[4] = guitarB
however, i want it to print to screen as
guitarA = qty 3
guitarB = qty 1
etc.
my question is:do i want to handle the "sum" at MySQL (i.e. is there a MySQL built-in-syntax which will do such a thing? [MySQL v.5.0 - PHP 5.current]. i'm far from being well versed in the art of SQL, so please don't take for granted that i might know even the simplest of functions [i can do date INTERVALS and simple joins like above, and that's about it!]), or would i be best to try to create the "sum" on the PHP side? seems like a MySQL thing to me but it's just a hunch.
thanks!!!
PS. i also want to be able to report an "out-of-stock" item (at least in the 'backend'). hmm... i think i can tackle that it, but i'd appreciate any insight into a solution to the idea of maintaing an "active" inventory (ie. one which changes depending upon goods sold, and should reflect this status to prospective customers).
thank you!!