Ask a Question related to PHP Development, Design and Development.
-
Karzy #1
newbie question on count()
I have been driving myself crazy for hours now on a simple (I thought)
little deal. I've given up and come for some help. Below is my code
snippet. When the count returns 0 it doesn't print 0, but instead wipes
out everything on my screen. All I want is for it to print 0 when
appropriate.
<connect>
$sql = "select count(print_id) FROM new_table, players WHERE
players.player_id = new_table.player_id and grad_year = '2003-2004' and
contact_coach = '' and eval_rank not in ('0','8','9')";
$result = @mysql_query($sql, $connection) or die(mysql_error());
$count_ua = @mysql_result($result,0,"count(print_id)") or die
(mysql_error());
<disconnect>
<li><a href="unassigned_coach.php">Unassigned People In System:</a> <b>
<?PHP echo "$count_ua"; ?></b></li>
Thanks for any help. I really appreciate it.
Mike
Karzy Guest
-
SIMPLE Question! - Count <cfloop>
How can I display the number of times a query loops? Example: <cfloop query="countthis"> ?? </cfloop> So, if the query produced 10 results,... -
Pen Tool Use Question. (Embarrassingly Newbie Question)
I'm currently using Flash MX and whenever I choose the Pen Tool instead of the pen nib with the small "x" beside it that supposed to show up on... -
[mysql] SELECT COUNT(*) question
Is something like the following possible? SELECT products.id, count(*) as counter FROM products, keywords WHERE keywords.keyword in... -
newbie : trying to count records in mysql table
Help, I get no output on this code // Connect to database. $dbh = mysql_connect("localhost","user","password"); mysql_select_db("survey"); ... -
HELP! Having Count Question
On 16 Dec 2002 12:46:29 -0800, kellywh@hotmail.com (oranewbie) wrote: .... .... or triplicates, or quadriplicates, etc. Jaap. -
Jon Trelfa #2
Re: newbie question on count()
On Thu, 18 Sep 2003 02:19:53 +0000, Karzy wrote:
> $sql = "select count(print_id) FROM new_table, players WHERE
> players.player_id = new_table.player_id and grad_year = '2003-2004' and
> contact_coach = '' and eval_rank not in ('0','8','9')";
>
> $result = @mysql_query($sql, $connection) or die(mysql_error());
>
> $count_ua = @mysql_result($result,0,"count(print_id)") or die
> (mysql_error());
How about these changes?
<snip>
$sql = "SELECT count(new_table.print_id) FROM new_table, players...
<snip>
$count_ua = mysql_result($result,0);
<snip>
You don't have to specify the column you're requesting because you're
pulling 1 column from your data set. Also, you'll notice that the column
name in your SQL query should be defined by its parent table since you're
pulling from multiple tables (this is a join type of query).
HTH,
--
Jon Trelfa
Registered Linux User #164332
There 10 kinds of people in this world...
Those who understand binary and those who don't
Jon Trelfa Guest
-
Jan Pieter Kunst #3
Re: newbie question on count()
In article <MPG.19d2d261757060479896c2@netnews.mchsi.com>,
Karzy <mkarr@mchsi.com> wrote:
I don't have a solution, but I have a (general) tip: leave out those @> $result = @mysql_query($sql, $connection) or die(mysql_error());
>
> $count_ua = @mysql_result($result,0,"count(print_id)") or die
> (mysql_error());
signs before function calls when you are debugging. You are probably
supressing helpful error messages.
JP
--
Sorry, <devnull@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jan Pieter Kunst Guest
-
Karzy #4
Re: newbie question on count()
In article <pan.2003.09.18.03.09.57.243000@nobleaccord.com> ,
[email]treefrog@nobleaccord.com[/email] says...Thanks a bunch. Now I can sleep peacefully.> On Thu, 18 Sep 2003 02:19:53 +0000, Karzy wrote:
>>> > $sql = "select count(print_id) FROM new_table, players WHERE
> > players.player_id = new_table.player_id and grad_year = '2003-2004' and
> > contact_coach = '' and eval_rank not in ('0','8','9')";
> >
> > $result = @mysql_query($sql, $connection) or die(mysql_error());
> >
> > $count_ua = @mysql_result($result,0,"count(print_id)") or die
> > (mysql_error());
>
Mike
> How about these changes?
>
> <snip>
>
> $sql = "SELECT count(new_table.print_id) FROM new_table, players...
>
> <snip>
>
> $count_ua = mysql_result($result,0);
>
> <snip>
>
>
> You don't have to specify the column you're requesting because you're
> pulling 1 column from your data set. Also, you'll notice that the column
> name in your SQL query should be defined by its parent table since you're
> pulling from multiple tables (this is a join type of query).
>
> HTH,
>
>
>Karzy Guest



Reply With Quote

