mardi 3 novembre 2015

generate random numbers and save in database

On my PHP/MYSQL BASED website sellers can post 10 items of the same kind and nature and value. I want users to be able to post qty = 10, value = 100. (values are preset in a dropdown and selected by sellers).

At the moment I am able to post a single item only for a preset value and a code is generated as shown in the code given below;

$sql_query = "INSERT INTO eg_posts(seller_id,value_id,quantity,cdate,egcode) VALUES ('$a','$bval','$cqty',now(),CONCAT( CHAR(FLOOR(RAND()*26)+65),FLOOR(100+RAND()*(5000-100))))";

The above post is saved with one item, with one alphanumeric code with a preset value chosen by the seller.

I want the user to be able to post more than one items (say 10) of the same kind and nature and value and I want 10 random alphanumeric codes to be generated for these 10 items. And I want all 10 random codes to be save in the database under the post ID.




Aucun commentaire:

Enregistrer un commentaire