Hi and thanks in advance. First let me say that I know barely anything about array's and I rarely use them. Except in this case I don't see any way around it.
Ok here is what I'm doing. I'm creating a quick stats page and counting items to do graphs with percentages. I'm counting helpdesk information like total open, closed and pending. Then counting the different priorities in each.
Well I've got it so that it counts the first part with no problem, so then theres the second part. Well each ticket stores a priority_id which refers to another table that stores the id, name and some other information.
Here is the code for the array:
## SET TICKET PRIORITY
$infoquery = "SELECT *
FROM hd_priority
WHERE hd_priority_id = '$hd_priority_id'";
$inforesult = mysql_query($infoquery);
while($infoitems = mysql_fetch_array($inforesult))
{
$hd_priority_id = stripslashes($infoitems["hd_priority_id"]);
$hd_priority_text1 = stripslashes($infoitems["hd_priority_name"]);
$hd_priority_color = stripslashes($infoitems["hd_priority_color"]);
}
$hd_priority[$hd_priority_id] += 1;
$hd_priority_name[$hd_priority_id] = $hd_priority_text1;
Ok. If I run the full program and then enter:
die("$hd_priority_name[1] -> $hd_priority[1]");
I''ll get something like Critical -> 5. So it's storing it correctly. My problem is that since items in the priority database can be changed and altered, there isn't a real way to know what the $hd_priority_id will be. It could be sequential like 1, 2, 3... or it could be really screwy and be like 1, 5, 15, 40...
Is there an easier way to step through the array and do my calculations and print stuff out. Or am I gonna just have to re-open the table and grab each id and do something like:
$infoquery = "SELECT *
FROM hd_priority";
$inforesult = mysql_query($infoquery);
while($infoitems = mysql_fetch_array($inforesult))
{
$hd_priority_id = stripslashes($infoitems["hd_priority_id"]);
print "$hd_priority_name[hd_priority_id] -> $hd_priority[hd_priority_id]";
}
While this will work, it's not really what I want to do. There has to be some proper way to do it and I just can't find it in my books or on this forum.
I hope all of this makes sense, if not let me know.