Reply to Re: [PHP] Help with logic :(

Your name:

Reply:


Posted by Dan McCullough on 10/10/05 23:24

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@martekbiz.com <aaronjw@martekbiz.com> 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
>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация