0

I have a database that looks like the following

table contents

In my database both id & fb_user_id are unique. Id is an auto incremented number.

First i would like to insert a new row for arguments say with the following

$new_first_name = "John";
$new_last_name = "Nolan";
$new_email = "[email protected]";
$new_link_url = "Johns_Link";
$new_signups = 0;
$new_order = $num_rows;
$referred_by = 2;
$new_fb_user_id = 4;

I use this insert statement

$New_Member = mysql_query("INSERT INTO `rotator`.`rotator` (`id`, `fb_user_id`, `first_name`, `last_name`, `email`, `link_url`, `referred_by`, `signups`, `order`) VALUES (NULL, '$new_fb_user_id', '$new_first_name', '$new_last_name', '$new_email', '$new_link_url', '$referred_by', '$new_signups', '$new_order');");

And because the person was referred by fb_user_id number 2 i want to update signups as follows

$update_sponsor_order = mysql_query("UPDATE `rotator`.`signups` = `rotator`.`signups` + 1 WHERE `rotator`.`fb_user_id` = $referred_by;");

This is where i am stuck. Maybe there is a better way to do it than inserting and updating the table as abovee.

What i would like to do now is something like the following select statement but assigning the returned values to a multi dimensional array. Basically i return columns fb_user_id and order where signups is less than 2

$get_link = mysql_query("SELECT `rotator`.`fb_user_id`, `rotator`.`order` FROM `rotator`.`rotator` WHERE `rotator`.`signups` < 2);

Now with my array i want to rotate everything that is in the column order and update the database of what entry is next in line....

Check the following question and replys to see what i am trying to do

Original Question

3

1 Answer 1

2

You're new best friend the pdo class. I know this doesn't exactly answer your question, but if you start using it now, you will thank me later.

Overview here http://www.php.net/manual/en/class.pdostatement.php

And to retreive results: http://php.net/manual/en/pdostatement.fetch.php

Sign up to request clarification or add additional context in comments.

1 Comment

Anyway you could help me out.... Would take me forever to learn how to use PDO statements and i need to get this done asap

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.