Jump to content

t_machine

Members
  • Posts

    104
  • Joined

  • Last visited

    Never

Posts posted by t_machine

  1. hi, I really hope someone can help with this problem.

     

    I have two tables. One stores userid, cur_timestamp(timestamp), earn(float 8,2)

    The second table has uid(this matches the userid), time_paid(timestamp), paid_amt(float 8,2)

     

    Table 1.

    +----+----------+---------------------+--------------+

    | id  | userid      | cur_timestamp        | earn

    +----+----------+---------------------+--------------+

     

    Table 2.

    +----+----------+---------------------+--------------+

    | id  | uid          | time_paid                | paid_amt

    +----+----------+---------------------+--------------+

     

     

    The first table adds a row each time a userid gets a money so there will be many entry for each userid.

    The second table stores each time the admin pays the userid.

    What i am trying to do is write a sql query to first check if the userid in table 1 has a sum of $50 and has not been paid yet or has earned $50 or more since the last payment(which should check table 2 to see if they received a payment yet).

     

    Thanks for any help on this. I do not even know where to start :(

     

     

  2. hi, I have a table that stores dates with the mysql CURRENT_TIMESTAMP. This stores each entry with the format (2008-11-12 00:11:08).

    The problem I am having is getting the results for the current date. The following query will explain what I mean.

     

    $sql = "SELECT * FROM my_table WHERE date_field = CURDATE()";

     

    This does not give any results even though the current date is the same as a few records in the database. Any help would be greatly appreciated.

     

    Thanks:)

  3. Thanks for the reply :)

     

    I tried this code so far but I am sure it's on the wrong path

     

      $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"),   date("Y"));
    $wsnow1 = date("F,Y", $lastmonth);
    $wsdformat = '%M,%Y'; 
      $sql = "SELECT COUNT(id) + 1 AS rank FROM {TOPUSER_TBL} WHERE id>(SELECT * FROM {TOPUSER_TBL} WHERE DATE_FORMAT(FROM_UNIXTIME(date_added), '".$wsdformat."') ='".$wsnow1."' AND userid='$mid') AND DATE_FORMAT(FROM_UNIXTIME(date_added), '".$wsdformat."') ='".$wsnow1."'";

  4. I'm wondering if anyone could help with this problem.

    I have a table that stores id(autoincrement), userid, date

    Each time a vote is casted a new entry is added to the table with the userid and current date. What i am trying to do is get the rank for that user last month by counting the amount of times their user id exists for the last month and comparing that to others for that month.

    I can't seem to construct a query for what i need done. Any help would be greatly appreciated.

     

    Thanks :)

  5. hi, i am using a tutorial I found that gets the image src, image type but does not show how to get the name itself.

     

    example:

    $data = 'Some text here <img src="images/myimg.jpg" border="0"> more text.';
       $pattern = "/src=[\"']?([^\"']?.*(png|jpg|gif))[\"']?/i";
       preg_match_all($pattern, $data, $images);
      echo $images[0][0]; //src=images/myimg.jpg
      echo $images[1][0]; //images/myimg.jpg
      echo $images[2][0]; //jpg 

     

    How can I get "myimg" from the src url?

     

    Thanks for any help :)

  6. Thanks for the replies :) I will expand a little on my example.

    In my example the "10" is defined but in my codes the number is determined by the results in a database. I am using the "for" loop to display the results and would like for it to reach the last result and echo some extra content.

     

    Thanks

  7. hi, i have a database that stores views to a user's profile. Is there a script i could use to sort the views and tell what number the user ranks in page views?

     

    example:

    user 1 (200 views)

    user 2 (400 views)

    user 3 (20 views)

    user 4 (1000 views)

     

    How can I tell where user 2 ranks with php? In this case it would be second..

     

    Thanks for any help.

     

  8. I hope someone can help with this as it is very important to the database script I am using.

    The script is used to cache msql queries but the aggregate() is stripped from php5.

     

    This is the aggregrate used

    aggregate($db, "sqlCache");

     

    I must also mention this is getting it's data from a class file so $db = new dbcon($host, $user,.....);

     

    How I can replace the aggregrate()? Any help is greatly appreciated. :)

     

     

  9. I have a table that has columns "id", "hits" and votes" .  Is there a way to write the sql query that will sum(hits)+sum(votes) and display the results where the totals are the largest.

     

    Any help will be greatly appreciated.

  10. I am wondering if anyone can help with this. I already know the basics of searching mysql but if the user has a space, it does not treat the search as "OR".

     

    Example:

     

    Seach phrase => "cool car"

     

    Notice the space? For some reason my results are only if the exact phrase cool car exists but not cool bike or red car.

    How can I have it search mysql and return any matches even if the phrase does not exists?

     

    Thanks :)

  11. Hi, I am wondering if this is possible. The following example will demonstrate what I would like to achieve.

     

    Example:

     

    $myarray = array("text1"=>"apples", "text2"=>"banana", "text3"=>"pineapple");

     

    $mystring = 'I like eating text1 but text3 is my favorite.';

     

     

    //result

    I like eating apples but pineapple is my favorite.

     

    How can I achieve the result using the array and string.

     

    Thanks for any help :)

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