Re: Help with logic :(

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



create a function to check if the rndnumber=couponcode row count = 0
if not then redo rndnumber if it does = 0 then insert rndnumber

On 10/10/05, aaronjw@xxxxxxxxxxxxx <aaronjw@xxxxxxxxxxxxx> wrote:
> Hey guys,
>
> Having trouble coming up with a solution to this idea I am trying to
> implement.
>
> I have a "Coupon" table.
>
> I am creating radonly generated coupon codes that go into this table. 12
> chars in length - both number and letters - all lowercase.
>
> I figure I need to do the following:
>
> 1) generate the radon coupon code;
>
> 2) Do query against thethe table to pull out all the currently entered codes;
>
> 3) Loop through all codes to see if any match the randomly generated code;
>
> 4) if a match exists, generate code again and keep doing this until we
> have a code that doesn't match;
>
> 5) If a match doesn't exist, insert code into DB and continue with rest of
> my process.
>
>
> What I am unsure of is how to loop through all codes in the DB and match
> against current randomly generated code and if a match exists, keep
> generating new random codes until one doesn't exist.
>
> Any ideas on how to go about this?
>
> Thank you in advance. Seems pretty simple I'm sure. Just confused on the
> logic.
>
> Thanks.
>
> Aaron
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux