random "card number" generator

random "card number" generator

am 24.11.2006 09:04:52 von coughlandesmond

--0-265556357-1164355492=:47994
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

X-No-Archive: true

Hello,
I'm learning PhP and trying to write a library catalogue system, that uses a PostgreSQL back-end. My db looks like this ...

http://www.chez.com/desmondcoughlan/unix/bibliotheque.sql

I had originally planned to have a username in place of 'card_number', but realised that there was no point. What I need now is the PhP code that will create a card number, and rather than having a sequence, I want a random three-digit number. Can someone point me in the direction of where and how PhP can do this?

Thanks.

D.


---------------------------------
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.
--0-265556357-1164355492=:47994--

Re: random "card number" generator

am 24.11.2006 10:12:07 von jeffreyb

D.

Go to the manual at http://be2.php.net/manual/en/function.rand.php and
look at the User contributed notes further down the page. You'll find a
couple of solutions.

Whatever you do, you will presumably need to check the generated number
against the db to see if it is already in use and, if not, generate a
new random number.

Good luck,

Jeffrey

Desmond Coughlan wrote:
> X-No-Archive: true
>
> Hello,
> I'm learning PhP and trying to write a library catalogue system, that uses a PostgreSQL back-end. My db looks like this ...
>
> http://www.chez.com/desmondcoughlan/unix/bibliotheque.sql
>
> I had originally planned to have a username in place of 'card_number', but realised that there was no point. What I need now is the PhP code that will create a card number, and rather than having a sequence, I want a random three-digit number. Can someone point me in the direction of where and how PhP can do this?
>
> Thanks.
>
> D.
>
>
> ---------------------------------
> Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.

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