Jump to content

xwishmasterx

Members
  • Posts

    186
  • Joined

  • Last visited

Posts posted by xwishmasterx

  1. I have a table where a filed called "recruitment" can either be "0" or "1"  Why does my below code not work?

     

    $sql_rec = ("SELECT * FROM teams WHERE team_id=".$_GET['t']." ");
    $rsrec = mysql_fetch_array($sql_rec);
    if($rsrec['recruitment'] == 1){
    echo "Your team is <b>OPEN</b> for all members to join <br>
    <a href='changemode0.php?t=".$_GET['t']."&r=".$_GET['r']." '>(click here to change mod)</a>";}
    elseif($rsrec['recruitment'] == 0){
    echo "Your team is <b>CLOSED</b> for all members to join <br>
    <a href='changemode1.php?t=".$_GET['t']."&r=".$_GET['r']." '>(click here to change mod)</a>";}

     

    to ask in another way: how do I make the if statement to check if the value is "1" or "0"?

  2. I am trying to create a simple form for inserting to a database table.

     

    It seems the data from the form are passed through the "insert" script, but nothing is added to the table.

     

    My question is: what is required to insert new data to a table? must all fields have a value for the new data to be added?

  3. I have a problem with the below code:

    <?php
    $sql_ranks = ("SELECT vtp_members.id, vtp_members.name, vtp_members.teamleader, teams.team_name, count(vtp_tracking.id) surfs
    FROM vtp_members, vtp_tracking, teams
    WHERE vtp_members.team_id=".$_GET['t']." AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date > '$last_sunday' AND vtp_tracking.action_date < '$next_sunday'
    GROUP BY teams.team_name
    ORDER BY surfs DESC");
    $rsranks = mysql_query($sql_ranks);
    echo "<br><table align='center' valign='top' border='0' width='300px'>
    <tr><td colspan='2' align='center'><font size='2px'><b>Team Rankings (Current Week)</b></font></td></tr>
    <tr><td><font size='2px'><b>Team</font></td><td align='right'><font size='2px'>Total Surfs</font></td></tr>";
    while ($row = mysql_fetch_array($rsranks)) {
    echo "<tr><td><font size='2px'><b>".$row[team_name]."</font></td><td align='right'><font size='2px'>".$row[surfs]."</font></td></tr>";}
    echo "</table>";
    ?>

     

    Problem is that the last output (".$row[surfs].") is the same for all teams. It seems it is not making a total of all id's and not per team_name.

     

    anyone can see what I am doing wrong. I need to sort by team_name and the surfs should display the total of the members with team_id is ".$_GET['t']."

  4. I have this little code that I cannot get to work

    $sql_buildings = ("SELECT castle, treasury, huts, [b]leader_id[/b] FROM teams WHERE team_id=[b]".$_GET['t']." [/b]");
    $rsbuildings = mysql_query($sql_buildings);
    
    if($rsbuildings[".$_GET['t']."] == 'leader_id' ){

     

    The problem is this part:

    if($rsbuildings[[b]".$_GET['t']."[/b]] == '[b]leader_id[/b]' ){

     

    How can I write it to have these to values work?

  5. what do you mean "outside of them"?

     

    My code is:

    echo " alot of text here and then treasure holdings: ".$row[team_treasure]." and some more text here"; 

    using your (and my) way just returns this:

    round(845.56999999999999,2)

  6. I have an error somewhere in the form as it does not output what I want it too. I know the form itself is working as I have added an echo to see if the form inputs are processed.

     

    the code:

    <?php
    $amount = $_POST['amount'];
    $member = $_POST['member'];
    
    $sql = ("SELECT name FROM vtp_members WHERE name=".$member." ");
    $result = mysql_query($sql);
    $numrows = mysql_num_rows($result);
    if($numrows = '1')
    {
      while($row = mysql_fetch_array($result, MYSQL_ASSOC))
        {
    echo "You sent ". $amount . " to " . $member . ".<br />";
    }
    }
    echo " ".$amount." and ".$member." ";
    ?>

     

    It outputs the last echo correct.

     

    is there anyone who can see what I'm doing wrong?

  7. I am need of some help on how to create a form with multiple receivers between tables.

     

    table1.field1 value is 10000

     

    the form should  allow a person to enter the id for those members to receive(separated by a comma) and the amount  they each receive from table1.field1

     

    then of course add the amount too each members account, and subtract the total from table1.field1 (and of course check if the value is high enough to distribute the desired amount between members.

     

    I need a little hand to get started here, so hopefully someone is willing to point me in the right direction

     

     

  8. Thats the last part of it..thank you for that!

     

    My "REAL" problem is I know how to get the info needed from the database, I just tried my script and it returned:

     

    Team 12 has surfed: 3 sites

     

    by using this code (end of it)

    while ($row = mysql_fetch_array($result)) {
    echo "Team ".$row[team_id]." has surfed: ".$row[surfs]." sites";}

     

    I don't know how to get these results and then apply you update code.

    The math part should be applied to the ".$row[surfs]." result, and then "UPDATE" into table 'teams' where ".$row[team_id]." = team_id

     

    I hope I make sense, just started learning php a few days ago.

  9. I am in need of suggestions on how too achive this:

     

    I have a surf exchange and whenever a member has viewv a site, it ads this members Id and time to a table called vtp_tracking.

     

    I have now created a team script, so I can count the total of surf for members within this team from the vtp_table.

     

    What I am in need of is this:

    I would like to add a bonus for the teams, so my idea was this: every hour run a cronjob to get the results for the last hour by team id lik so:

     

    WHERE vtp_members.team_id="teamid" AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date>date_sub(NOW(),interval 60 minute

     

    I believe the above code will work fine and get me the results for team members for the last hour.

     

    Problem: how can I get this result, multiple it with the value from another field and divide by 100  and add this to a third field?

     

    eg: (result from above * value from other field / 100) then add to a third field.

     

    Anyone willing to try and answer this one?

  10. I have two (2) forms on the same pages, each with 3 buttons. When a button is clicked, it will include the desired page. Since I have 2 of these forms, clicking one of them will refresh the page thus "delete" the info former retrieved from the other form.

     

    Is there a way to make the page "remember" the last form action?

     

     

  11. I tried, using the code you suggested:

     

    SELECT vtp_members.id, vtp_members.name, vtp_members.email, count(vtp_tracking.id) surfs
    FROM vtp_members, vtp_tracking
    ON vtp_tracking.credit_members_id=vtp_members.id 
    WHERE YEARWEEK(vtp_tracking.action_date = YEARWEEK(CURDATE())
    GROUP BY vtp_members.id
    ORDER BY surfs DESC

     

    This however did not return any results (and it should). Anyway I can do a test just return the result of YEARWEEK?

  12. Well, it's a little hard too explain, since I'm pretty new too all this php...

     

    I have a surf script, that add the the time, everytime a member views 1 page.

     

    So the code I posted, returns the name of the surfer and how many pages they've surfed.

    Problem is the code will show last 7 days from current date, and not this week. So..

     

    if I could make the codesomthing like this: "2011-03-28 10:40:30 > 2011-03-23 10:40:30",

    I could setup a cron to change the date every Sunday at midnight, by simple updating the "LESS THAN" value.

     

    Hope it makes sense

  13. Hi Keith

     

    I tried that, but couldn't get it too work.

     

    If I could use somthing like this: "2011-03-28 10:40:30 > 2011-03-23 10:40:30"

    it would be exellent, as I can setup a cron to change the dates!

    (maybe the "2011-03-28 10:40:30" could be converted to one number (20110323104030)?

  14. let me try asking anotherway , or alternativ; From the previous code:

     

    vtp_tracking.action_date > DATE_SUB(CURDATE(), INTERVAL 7 DAY)

     

    is there away to substitue "DATE_SUB(CURDATE(), INTERVAL 7 DAY)" with a specific date?

    I know the action.date format is "2011-03-28 10:40:30"

     

    but saying "2011-03-28 10:40:30 > 2011-03-23 10:40:30" ; doesn't really make sense.

     

     

  15. I have this piece of code that show the number of pages surfed for the last 7 days:

     

    SELECT vtp_members.id, vtp_members.name, vtp_members.email, count(vtp_tracking.id) surfs
    FROM vtp_members, vtp_tracking
    WHERE vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date > DATE_SUB(CURDATE(), INTERVAL 7 DAY)
    GROUP BY vtp_members.id
    ORDER BY surfs DESC

     

    How can I make it count for within a timeframe..say monday to monday?

     

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.