Re: A better solution?

From: Date: Mon, 04 Aug 2003 14:23:34 +0000
Subject: Re: A better solution?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-158155@lists.php.net to get a copy of this message
Ryan A wrote:
Hi, I have a table called the_slave where i am entering differient types of data and 5 specific "types", to get a count of each of the types i used: $tt = "SELECT ptype, count(*) FROM the_slave WHERE ptype IN ('1', '2', '3','4','5') and user='".$user."' and no='".$no."' GROUP BY ptype"; then to dump them into variables that I could use anywhere in the page, i used: if($res = mysql_query($tt)) { $x = 1; while($row = mysql_fetch_row($res))
I would not be so sure the rows are in the right order here, use { $var[$row[0]] = $row[1]; } instead of
{ $var[$x++] = $row[1]; } } In this way I could use it like: "Hello and welcome, you have: $var[1] of type 1" etc now i am facing a new problem, I need to do the same as above but from 5 differient tables (tabl1,tabl2,tabl3,tabl4 and tabl5) I can of course run 5 select/count queries but is there a way to run just one and get the same effect? I will need to dump it into an arrar and use it the way i used $var[] Any ideas? Thanks, -Ryan We will slaughter you all! - The Iraqi (Dis)information ministers site http://MrSahaf.com


« previous php.general (#158155) next »