Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

selecting certain data from a table

Codes here !

Moderators: macek, egami, gesf

selecting certain data from a table

Postby tinboye22 » Thu Jul 10, 2003 1:06 am

hello, I been looking all night but I cannot figure this out.
I have this script where one of the rows in a mysql table is
named "type" tinyint(3)

now when a person joins the site they have a basic membership and their data is 0 in the type row
when they become silver members it is 1
and gold is 2 all 3 numbers are entered into that one row for each member depending on what kind of membership they have.

Hopefully this makes sense. LOL

what I want to do is echo each type of membership on a page by the total number of each type
so say there is 100 basic memberships

then it would add up all the 0's within the row in the mysql database and then echo that total.


I have already gotten it to display total number of users by adding

$query = "select id from user";
$result = MYSQL_QUERY($query);
$totalusers=mysql_num_rows($result);
@mysql_free_result($result);

if(($s=="")or($s>=$totalusers)or($s<0)){
$s=0;
}

and then having <?print $totalusers;?> where ever I want it to echo.

How can I do the same with the memberships? I have a feeling that it would have something to do with $totalusers=mysql_num_rows($result); i need to change mysql_num_rows to something else?

please help!!


Thanks
tinboye22
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sun Mar 09, 2003 2:43 pm

Postby bezmond » Thu Jul 10, 2003 1:21 am

$query = "select id from user WHERE type='$type'";

where $type is a value from 1 to 3...

Andrew
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Postby tinboye22 » Thu Jul 10, 2003 1:29 am

thanks that worked, I did try that but I never had the ' '
tinboye22
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sun Mar 09, 2003 2:43 pm


Return to mySQL & php coding

Who is online

Users browsing this forum: freshnet and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.