Jump to content

xwishmasterx

Members
  • Posts

    186
  • Joined

  • Last visited

Posts posted by xwishmasterx

  1. I have 2 tables which both contains timestamp (same format). I am trying to do a count from one of the tables and need to do the count where the DATES are the same I have tried this:

     

    WHERE DATE(teamwar_info.war_started) = DATE(vtp_tracking.action_date)

     

    I am getting a result, but not the right one.

     

    If I do like this:

     

    DATE(teamwar_info.war_started) = curdate() 

     

    It counts all values found.

     

    How do I do a count where the date for teamwar_info.war_started and vtp_tracking.action_date are the same?

  2. I have this code below:

     

    members_count <= ".$diff." || members_count >= ".$defmemcount."

     

    My test says $diff = 6 and $defmemcount = 11, members_count = 14

     

    So how come this returns as if members_count isn't less or equal to 6 OR higher or equal to 11?

  3. I have this part of an UPDATE code this seems to return a value no matter what I set it too:

     

    AND team_treasure>=((members_count)*1000) 

     

    although members_count times 1000 is much higher than team_treasure it still returns as if it is equal or lower.

     

    Can someone help me on how to write this simple calculation?

  4. I am using the below code for todays count and it works fine:

     

    ...AND left(vtp_tracking.action_date,10) = CURDATE()

     

    I was hoping I could use the below code to select yesterdays count:

     

    ....AND left(vtp_tracking.action_date,10) = CURDATE(), INTERVAL 1 DAY)

     

    but doesnt seem to work.

     

    Is there anything I am missing (there must be)?

     

     

  5. Below is part of my existing code:

     

    UPDATE vtp_members SET hits=(hits + $random_number)

     

    Can I update same field again like so?:

     

    UPDATE vtp_members SET hits=(hits + $random_number), hits=(hits + 100)

     

    Any problems with this or will it work and add both the random_number and +100 to the filed?

  6. I am trying to to create an if statement checking the domain name. I need to check the domain with "www" and without the "www". How can I make an OR inside an if statement "||" doesn't seem to work? I have tried this code, but doesn't work:

     

    if (($_SERVER['HTTP_HOST'] != 'www.domain.com')||($_SERVER['HTTP_HOST'] != 'domain.com')){

    echo "some text here":}

  7. I have a simple code that should count my online members for a team:

     

    $online_members = mysql_query ("SELECT count(vtp_tracking.credit_members_id) as members FROM vtp_tracking WHERE action_date>date_sub(NOW(),interval 10 minute) AND teamid=".$rsget_team_id['team_id']." GROUP BY credit_members_id")
      or die(mysql_error()); 
    $rs_online_members = mysql_fetch_array( $online_members );

     

    my problem is getting the actual count, as I get the wrong amount of online members. Basicaly I count the unique member id where the team id is the same as the user (teamid=".$rsget_team_id['team_id']." ).

     

    What should I group by to count the numbers of different "vtp_tracking.credit_members_id" ?

  8. I think I found a way to add the team_id to the tracking table, but cannot seem to get it just right. Found this piece of code:

     

     //Add to Tracking
    	      $remote_ip = $_SERVER[REMOTE_ADDR];
    	      $UPD_SQL = "INSERT INTO vtp_tracking(credit_members_id,debit_members_id,url_id,action_date,remote_ip,teamid)
    	        VALUES('$members_id','$url_members_id','$url_id', NOW() , '$remote_ip' );";

     

    So I added a column in above table named teamid (added this to above code also).

     

    how can I add the result of this query to the above code VALUES?:

     

    $sql= "SELECT team_id FROM vtp_members WHERE id=$members_id";
      $result = mysql_fetch_array( $sql );

     

     

     

  9. I am trying to do a query for members in my database but I need to go through different tables to get those members I want. Let me try too describe:

     

    I want the members who has same team_id as current member (from same table)

    I want only the members who are online (from another table where time stamps are, which has members id, but not team id)

     

    I simply cannot figure out how to only get members with same team id as the current member, from the table with time stamps.

     

    Anyone can point me in the right direction, or is the above just not making sense at all?

     

     

  10. I have a this piece of code, and simply need to make the last piece work:

    $amount = $_POST['amount'];
    .........
    $query = mysql_query("SELECT * FROM teams WHERE team_id='$te' ") 
    or die(mysql_error());
    $result = mysql_fetch_array( $query );
    if($result['team_treasure'] <= '$amount'){
    echo "<br><br><div align='center'>Transfer Failed: Not enough credits</div>  ";}
    else
    {
    echo "<br><br><div align='center'>Transfer Completed!</div>";}

     

    It returns Transfer Completed!, no matter if team_treasure is higher or lower than $amount

  11. I am not getting the result I am hoping for. The code below is full code after a form has been submitted containing a member name and amount of credits:

     

    <?php
    if (isset($t)){
    $t = $_GET['t'];}
    ?>
    <?php
    $amount = $_POST['amount'];
    $member = $_POST['member'];
    
    $sql = ("SELECT vtp_members.name, vtp_members.team_id FROM vtp_members WHERE vtp_members.team_id=".$_GET['t']." AND vtp_members.name='$member' AND teams.team_treasure >= '$amount' ");
    $result = mysql_query($sql);
    $numrows = mysql_num_rows($result);
    if($numrows == '1')
    {
      $sql2 = "UPDATE vtp_members, teams SET vtp_members.hits=(vtp_members.hits + '$amount'), teams.team_treasure=(teams.team_treasure - '$amount')
    WHERE vtp_members.name='$member' AND teams.team_id=".$_GET['t']." ";
    $results2 = mysql_query($sql2);
    $row2 = mysql_fetch_row($results2);
    $tmap2 = $row2[0];
    
    echo "You sent ". $amount . "credits to " . $member . ". ";
    }
    else
    {
    echo "The treasure holdings are too low for this transfer<br>(or an error occured)";}
    
    ?>

     

    Problem; it returns the else statement although the "teams.team_treasure" is higher or equal to  "$amount"

  12. I have the below code:

     

     $buttons = "button+='<table height=\"40\" border=\"0\"id=\"table1\"cellspacing=\"0\"cellpadding=\"2\"><tr><td>---PLACE CODE HERE---</td><td valign=\"bottom\">';\n";

     

    between the to cell tags (<td>---PLACE CODE HERE---</td>) I need to add this code:

     

    document.getElementById('com').innerHTML=<?php echo $gSurfMultiLoadedText; ?>+button2;

     

    My problem is the '; " and \" stuff :) Anyone care to show how I can merge these pieces?

  13. Hello I am trying to only display results within the time period last sunday too next sunday. my code:

    <?php
    $today = date('Y-m-d H:i:s');
    $time = strtotime($today);
    $last_sunday = strtotime('last sunday', $time);
    $next_sunday = strtotime('next sunday', $time);
    $format = 'Y-m-d H:i:s';
    $last_sunday = date($format, $last_sunday);
    $next_sunday = date($format, $next_sunday);
    ?>
    <?php
    $sql_totalsurfs = ("SELECT vtp_members.id, vtp_members.name, vtp_members.teamleader, vtp_tracking.Timber, vtp_tracking.Stone, vtp_tracking.Marble, 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 vtp_members.id
    ORDER BY surfs DESC LIMIT 0, 10");
    $rstotalsurfs = mysql_query($sql_totalsurfs);
    $numrows = mysql_num_rows($rstotalsurfs);
    .......

     

    Is there and error somwhere in the code?

  14. I need to do and UPDATE right after and need that value in the WHERE clause. if I have this:

     

    $query2  ="SELECT team_id FROM vtp_members WHERE id=".$_GET['r']."  ";
    $result2 = mysql_query($query2);
    $numrows2 = mysql_num_rows($result2);
    if($numrows2 == '1')
    {
      while($row = mysql_fetch_array($result2, MYSQL_ASSOC))
        {

     

    what can I then use to  UPDATE xxxxx WHERE team_id ='$result2???' or how should that look?

  15. Am unalbe to figure out how to get a value from a database and use it later on. If I have a simple query:

     

    $query2  ="SELECT team_id FROM vtp_members WHERE id=".$_GET['r']."  ";
    $result2 = mysql_query($query2);

     

    How can I "store" the value to use later one? can I do something like: $teamvalue = $result2? (there will only be one value /result)

×
×
  • 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.