RE: [PHP-DB] Re: Getting Percentage of coloumn value

2002-07-10 Thread joakim . andersson

" .
mysql_error());
$row = mysql_fetch_array($result);

$query = "select referer,(count(referer) / {$row['num_rows']} * 100) as
total_in_percentage from tececo_stats group
by referer";
$result = mysql_query($query) or die("Query failed: $query" .
mysql_error());
?>



{$row['referer']}{$row['total_in_percentage']}";
}
?>





Regards
Joakim Andersson

> -Original Message-
> From: JJ Harrison [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 10, 2002 8:30 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Re: Getting Percentage of coloumn value
> 
> 
> Here is my script:
> 
>  include "includes/required.php";
> do_html_header('Name Here');
> 
> $query = "select @total_items=count(id) from tececo_stats";
> $query1= "select referer,count(referer)/@total_items from 
> tececo_stats group
> by referer";
> $result = mysql_query($query) or die("Query failed: $query" .
> mysql_error());
> $result1 = mysql_query($query1) or die("Query failed: $query1" .
> mysql_error());
> $num_results = mysql_num_rows($result);
> ?>
> 
>  for ($i=0; $i < $num_results; $i++)
>   {
>  $row = mysql_fetch_array($result1);
>  echo
> ''.$row['referer'].''.$row['count(referer)'].
> '';
>  }
>  ?>
>  
>   
> 
> do_html_footer();
> ?>
> 
> How can I echo count(referer) ?
> 
> I currently get this error
> 
> Warning: Undefined index: count(referer) in
> C:\Inetpub\TecEco_PHP\stats_interface\referer_base.php on line 16
> 
> 
> --
> JJ Harrison
> [EMAIL PROTECTED]
> www.tececo.com
> 
> "Jj Harrison" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Could some one give me an idea as to what I SQL query could 
> use to get the
> > percentages of each differant colomn value.
> >
> > ie if this was my table:
> > +---+---+
> > | name   | id |
> > +---+---+
> > | foobar  | 1 |
> > | foobar  | 2 |
> > | foobar  | 3 |
> > | barfoo  | 4 |
> > +---+---+
> >
> > I would get this result(Then later do stuff with it in PHP):
> >
> > +---++
> > | name  | percent |
> > +---++
> > | foobar | 75|
> > | barfoo | 25|
> > +---++
> >
> > Thanks in advance,
> >
> >
> > --
> > JJ Harrison
> > [EMAIL PROTECTED]
> > www.tececo.com
> >
> >
> >
> >
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re: Getting Percentage of coloumn value

2002-07-09 Thread JJ Harrison

Here is my script:

" .
mysql_error());
$result1 = mysql_query($query1) or die("Query failed: $query1" .
mysql_error());
$num_results = mysql_num_rows($result);
?>

'.$row['referer'].''.$row['count(referer)'].'';
 }
 ?>
 
 

How can I echo count(referer) ?

I currently get this error

Warning: Undefined index: count(referer) in
C:\Inetpub\TecEco_PHP\stats_interface\referer_base.php on line 16


--
JJ Harrison
[EMAIL PROTECTED]
www.tececo.com

"Jj Harrison" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Could some one give me an idea as to what I SQL query could use to get the
> percentages of each differant colomn value.
>
> ie if this was my table:
> +---+---+
> | name   | id |
> +---+---+
> | foobar  | 1 |
> | foobar  | 2 |
> | foobar  | 3 |
> | barfoo  | 4 |
> +---+---+
>
> I would get this result(Then later do stuff with it in PHP):
>
> +---++
> | name  | percent |
> +---++
> | foobar | 75|
> | barfoo | 25|
> +---++
>
> Thanks in advance,
>
>
> --
> JJ Harrison
> [EMAIL PROTECTED]
> www.tececo.com
>
>
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php