Search
Left Quote    It is possible to store the mind with a million facts and still be entirely uneducated.
- Alec Bourne    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: How does the table look like?
  This user is offline  UnknownZ
  Subject: "How does the table look like?" Posted: @ 5:25 pm on Jun 02 2005   
Member #: 47
Rank: User - (29)
Since: 06/02/05
Posts: 29

What kind of table should I create to have this command running?

Code:
$Db->query( "UPDATE stats SET value=value+1 WHERE name='total_mem bers' LIMIT 1;";



Is it something like this?

Code:

CREATE TABLE stats (
value int(10) NOT NULL auto_increment,
name varchar(100) NOT NULL default '',
total_members varchar(100) NOT NULL default '',



And how does the table look like actually? Something like this?
--------------- ------
Value|Name|
--------------- ------
1|total_members
--------------- -------

Sorry, I am completely beginner here...


    Viewed: 9,973 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: How does the table look like?" Posted: @ 6:10 pm on Jun 02 2005    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

why would name = 'total_members '? I think that should be a variable ($total_members ). BTW, where did you get this query?

If you have phpMyAdmin, you can create tables alot easier. When I get off work, I can get you more details on the SQL of the table.

But it looks like you've got a table named "stats&q uot; that has two columns, "value&q uot; and "name.&q uot;



Edited at 06:13:06 pm on 06/02/05


-bs0d | AllSyntax.com

    Viewed: 9,499 Times | Reply to This | To top
  This user is offline  UnknownZ
  Subject: "re: How does the table look like?" Posted: @ 6:18 pm on Jun 02 2005    
Member #: 47
Rank: User - (29)
Since: 06/02/05
Posts: 29

This is the signup.php file..the sign up process is working, but it is not updating the Total Members..


Code:


<?php
require "start.ph p";
//------------ --------------- ---
$Display->a dd_title(" ;Register for Mysite.com&quo t;
if($User->l ogged != TRUE){
if(!$_POST[' submit']){
$Display-> ;output .= $Display->lo ad_template(&q uot;signup&quo t;
$Display-> ;output();
}else{
// check user
if($Vars-> ;POST['user'] != ""{
if(($match = match_alnum($Va rs->POST['u ser'], 5,"Userna me") === TRUE){
$user = $Vars->POST[ 'user'];
}else{
$error[] = $match;
}
}else $error[] = "No username entered." ;
// check pass
if($Vars-> ;POST['pass'] != ""{
if(($match = match_alnum($Va rs->POST['p ass'], 5,"Passwo rd") === TRUE){
$pass = md5($Vars->P OST['pass']);
}else{
$error[] = $match;
}
}else $error[] = "No password entered." ;
// check email
if($Vars-> ;POST['email' ] != ""{
if(($match = match_email($Va rs->POST['e mail'])) === TRUE){
$email = $Vars->POST[ 'email'];
if($Vars-& gt;POST['email _priv']){
$priv_ema il = '1';
}else $priv_email = '0';
}else $error[] = "The email address you entered is invalid." ;
}else $error[] = "No email address entered." ;

// check bday
if($Vars-> ;POST['bday_mo nth'] && $Vars->POST[ 'bday_day'] && $Vars->POST[ 'bday_year']) {
if(checkdat e($Vars->POS T['bday_month '],$Vars->PO ST['bday_day' ],$Vars->POS T['bday_year' ])){
$timestamp = @mktime(0,0,0,$ Vars->POST[ 'bday_month'], $Vars->POST[ 'bday_day'],$ Vars->POST[ 'bday_year']);
// date exists;
if(($match = checkCOPPA($tim estamp)) === TRUE){
$bday_day = $Vars->POST[ 'bday_day'];< br /> $bday_mon th = $Vars->POST[ 'bday_month'] ;
$bday_yea r = $Vars->POST[ 'bday_year'];
$bday_pri v = $Vars->POST[ 'bday_priv'] == '1' ? '1' : '0';
}else $error[] = $match;
}else $error[] = "Please check the date you entered. It does not seem to have ever existed." ;
}else $error[] = "Part of your 'birthday' was missing. Please make sure it is correct." ;

// check gender
if($Vars-> ;POST['gender ']){
$gender = $Vars->POST[ 'gender'] == 'f' ? 'f' : 'm';
$gender_pri v = $Vars->POST[ 'gender_priv' ] == '1' ? '1' : '0';
}else $error[] = "Please enter your Gender.";
if($_POST[' tos'] != 1){
$error[] = "You <b>MUST ACCEPT AND AGREE</b> to the Terms Of Service/Use <b>and< ;/b> the Disclaimers!&q uot;;
}
if(!isset($e rror)){
if(!$Db-> ;fetch("S ELECT * FROM /members WHERE username='{$us er}'"){
$query = "INSERT INTO /members VALUES(";
$query .= "NULL, '{$user}', '{$pass}', '{$email}', '{$priv_email} ', '1', '".time( )."', '', '/signup.php' , '', '',"; $query .= "'{$bday _month}', '{$bday_day}' , '{$bday_year} ', '{$bday_priv} ', '{$gender}', '{$gender_priv }','".t ime()."' ,'0','" ;.$_SERVER['RE MOTE_ADDR'].& quot;');" ;;
if($Db-> ;query( $query )){
// Update the total members stat:
$Db->query( "UPDATE stats SET value=value+1 WHERE name='total_me mbers' LIMIT 1;";
$_SESSION ['user']['us er'] = $user;
$_SESSION ['user']['pa ss'] = $pass;
if($User- >logged == TRUE) echo "logged& quot;;
$Display- >output .= $Display->lo ad_template(&q uot;signed_up& quot;
$Display- >output(); }else{
die(&quo t;Error!!!!&qu ot;
}
}else{
$Display-& gt;message(&qu ot;Someone has already signed up with the username: {$user}. Please pick another.<br& gt;<br>&l t;a href=javascript :history.back() >Click here</a> to go back.";
}

}else{
foreach($er ror as $k => $v){
$out .= "<b> ;".($k+1) ."</b& gt {$v} <br /><br> ";
}
$out = "<font class=msg style='font-si ze:14px'>Er ror!</font&g t;<br>The following errors occorred:<br ><br> ".$out.&q uot;Please attempt to fix them before continuing.< br><br> ;<a href=javascript :history.back() >Click here</a> to go back."; $Display-&g t;output .= $out;
$Display-&g t;output();
}
}
}else{
$Display-> message(" You are already signed up with the username: {$User->name }";
}
?>



This is where the Total Members will be showed up:

Code:

<tr><t d bgcolor=#ffffff >Total Members</td& gt;
<td bgcolor=#ffffff >
<?php

$number = $members = $Vars->stats ['total_member s'];
echo "<a href=\"/ memberlist.php \">&q uot;.number_for mat($number).& quot;</a> ";

?>
</td>< /tr>



Thanks.




    Viewed: 9,494 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: How does the table look like?" Posted: @ 6:27 pm on Jun 02 2005    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

hrm... your code looks kinda weird. Did you write that? you have === in alot of places, im not so sure thats correct syntax, but I could be wrong.

*EDIT: Ok, I guess it was introduced in php4 meaning "identica l"-

You dont necessairly need to keep a running total of the members as a column in the table, just echo mysql_num_rows( $users) and that will tell you how many.



Edited at 06:35:43 pm on 06/02/05


-bs0d | AllSyntax.com

    Viewed: 9,491 Times | Reply to This | To top
  This user is offline  UnknownZ
  Subject: "re: How does the table look like?" Posted: @ 6:33 pm on Jun 02 2005    
Member #: 47
Rank: User - (29)
Since: 06/02/05
Posts: 29

no, it's not coded by me..that script is quite old, from year 2003 and I just got it from someone else because it has nice design and features, but after running it, there are a lot of bugs everywhere..and since I am not a programmer, I don't really know how to fix it.

Currently I am able to show the Total Members by using this code:

Code:


<tr><t d bgcolor=#ffffff >Total Members</td& gt;
<td bgcolor=#ffffff >

<?php
$result = mysql_query('S ELECT COUNT(*) as MemberCount FROM members') or die('Unable to get number of registered members.');
echo '<a href="../ memberlist.php ">', mysql_result($r esult, 0) ,'</a>' ;
?>
</td>< /tr>



It was suggested by someone that it will be efficient to use this code rather than by updating it everytime users sign up...but I am just really not sure..and there is actually another bug, the Total Guest, Members and Staff could not show up...currently I could manage to show the Total "Users&q uot;..



Edited at 05:32:46 pm on 06/05/05


    Viewed: 9,484 Times | Reply to This | To top
  This user is offline  UnknownZ
  Subject: "re: How does the table look like?" Posted: @ 6:41 pm on Jun 02 2005    
Member #: 47
Rank: User - (29)
Since: 06/02/05
Posts: 29

This bug has been fixed too... ..3 days 2 night without sleep (only 3 hours) finally pay off..



Edited at 05:30:32 pm on 06/05/05


    Viewed: 9,481 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: How does the table look like?" Posted: @ 3:09 pm on Jun 08 2005    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

 Unknow nZ said...

< i>This bug has been fixed too... ..3 days 2 night without sleep (only 3 hours) finally pay off..


LOL, sometimes thats what it takes!




-bs0d | AllSyntax.com

    Viewed: 9,462 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank