Jump to content

Search the Community

Showing results for tags 'users'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 6 results

  1. Here's what I am trying to do. Users Table user_id, sponsor_id, username, filled_positions, position_1, position_2, position_3, position_4, position_5 1 0 user 1 4 user 2 user 3 user 4 user 5 2 1 user 2 2 user 4 user 5 3 1 user 3 4 2 user 4 5 2 user 5 Above is a "Users" table. Here's what I am trying to do. Insert new users into the table. Say I already have the users table set up with 5 users. I want to add User 6. I want to loop through the users in the table and find the next empty position and update it with the new user id. In this scenario diagram above, the next empty position is Row 1 - position_5. The one after that is Row 2 - position_3 and then Row 2 - position_4...etc. It basically loops through rows and checks each position. So User 6 will be placed under Row 1 - position_5 and User 7 will be placed under Row 2 - position_3. How can one go on about doing that?
  2. This is what I am trying to accomplish. 1. I have two tables. T1: Users and T2: Earnings. 2. I want to find a single random user whose deposit amount is greater than the listed amount. Below is my foreach loop within foreach loop trying to do the above. I was wondering if there is a more simple way to do this task? Is there a way to combine these two queries together? $listed_amount = 1000; // find a random user $find_user = $db->prepare("SELECT user_id FROM users WHERE user = :user AND active = :active ORDER BY RAND() LIMIT 1"); $find_user->bindValue(':user', 1); $find_user->bindValue(':active', 1); $find_user->execute(); $result_user = $find_user->fetchAll(PDO::FETCH_ASSOC); if(count($result_user) > 0) { foreach($result_user as $row) { $user_id = $row['user_id']; // find that random user's deposit amount $get_deposits = $db->prepare("SELECT deposit FROM earnings WHERE sent_to = :sent_to AND status = :status"); $get_deposits->bindParam(':sent_to', $user_id); $get_deposits->bindValue(':status', 1); $get_deposits->execute(); $result_deposits = $get_deposits->fetchAll(PDO::FETCH_ASSOC); if(count($result_deposits) > 0) { $ub = 0; foreach($result_deposits as $key=>$row) { $ub+= $row['deposit']; } $total_deposits = $ub; } if($total_deposits > $listed_amount) { // show the user } else { // hide the user } } }
  3. Say I have 5 users. Each user will receive their payment based on their individual percentage. For eg. User 1: 5% User 2: 10% User 3: 15% User 4: 15% User 5: 5% Now say I have a total of $100. I want to divide the $100 among the 5 users. But the users with higher % will receive a higher amount than the the ones with lower %. How would I calculate this?
  4. Hi We had an online aptitude test written for us back in 2004/2005. A user registers on our site then can take a test that evaluates what type of learner they are. After they complete the test, we can send them a .pdf report. The front end of our site is a wordpress site, the testing center is written in php. Once a user registers, they get a link on our site that sends them out of wordpress to the PHP testing pages. Question: if we have 4-5 users sign up at once ( which isn't a problem in wordpress ), is there a way to allow for those users to take the aptitude test all at once. As of now, the "testing center" part of our site is only allowing 1 user at a time. Is this how PHP works? Is it the hosting server? We are hosted by Network Solutions. The test is around 120 questions long and 3 pages. Thanks in advance.
  5. I currently have a php code at the top of the page that would automatically delete a user from the database if a certain condition isn't met before 24 hours. This code is processed no matter where you are on the site. I have two questions. 1. Will this be an issue if the database has thousands of users? 2. Is there a better way to do this?
  6. Say I have this records table. RECORDS TABLE record_id | sponsor_id | user_id | plan_id ------------------------------------------------------------------------------ 1 user5 user6 5 // I am this user. 2 user3 user5 3 3 user3 user4 4 4 user2 user3 4 5 user2 user2 2 6 user0 user1 5 I am "user6" and my sponsor is "user5". What I want to do is find the same "plan_id" from my sponsors, no matter how far up I have to do. For eg. My current plan id is "5". My sponsor is "user5". If I look for "user5" in the user_id column, I would find that he only has plan "3" id. So I go to his sponsor, which is "user3" and find him in the user_id column. That user's plan id is "4" so it does not match my plan id either. I repeat the same process by going to his sponsor and his sponsor and so on until I find the plan id that matches me. So for this table example, that would be "user1". I only want to retrieve the first result that matches my plan id. How do I go on about coding this function? Normally I can do these queries to go up limited amount. But I am looking for a more proper function that lets me search my sponsors unlimited times. $find_plan_id = $db->prepare("SELECT sponsor_id, plan_id FROM records WHERE user_id = :user_id"); $find_plan_id->bindParam(':user_id', $user_id); $find_plan_id->execute(); $result_find_plan_id = $find_plan_id->fetchAll(PDO::FETCH_ASSOC); if(count($result_plan_id) > 0) { foreach($result_plan_id as $row) { $get_sponsor_id_1 = $row['sponsor_id']; $get_plan_id_1 = $row['plan_id']; } if($get_plan_id_1 == $my_plan_id) { echo 'Plan id matches.'; } else { $find_plan_id_2 = $db->prepare("SELECT sponsor_id, plan_id FROM records WHERE user_id = :user_id"); $find_plan_id_2->bindParam(':user_id', $get_sponsor_id_1); $find_plan_id_2->execute(); $result_plan_id_2 = $find_plan_id_2->fetchAll(PDO::FETCH_ASSOC); if(count($result_plan_id_2) > 0) { foreach($result_plan_id_2 as $row) { $get_sponsor_id_2 = $row['sponsor_id']; $get_plan_id_2 = $row['plan_id']; } if($get_plan_id_2 == $my_plan_id) { echo 'Plan id matches.'; } else { // repeat the process } } } }
×
×
  • 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.