PHP MySql script

Codes here !

Moderators: macek, egami, gesf

Post Reply
seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: PHP MySql script

Post by seandisanti » Thu Apr 25, 2013 8:08 am

Its a simple enough project that I'll just do it for you, and if you feel like making a donation based on the result, all the better. send a pm to discuss specifics

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: PHP MySql script

Post by seandisanti » Thu Apr 25, 2013 2:06 pm

Just in case it would help anyone else, I created 2 triggers for him, one before insert on his user table, and one for after. The trigger that fired before insert grabbed a random number from his number table like this:

Code: Select all

CREATE TRIGGER bi_users BEFORE INSERT ON users
FOR EACH ROW SET NEW.rand_num = (SELECT anumber FROM a_table ORDER BY RAND() LIMIT 1);
After the insert was completed the next trigger fired (so it would only execute on successful insert)

Code: Select all

CREATE TRIGGER ai_users AFTER INSERT on users
FOR EACH ROW DELETE FROM a_table WHERE anumber = NEW.rand_num;
There were a number of ways to accomplish this result but that one did it without having to add or modify any tables or php files.

Post Reply

Who is online

Users browsing this forum: freshnet and 1 guest