[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 06-29-2005, 07:14 PM   #1 (permalink)
Senior Member
 
Join Date: Apr 2005
Location: .ma.us
Posts: 1,783
21.95 NP$ (Donate)

DropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to behold

Baby Health Save a Life Save The Children
MYsql

I want to make it so people can enter their email into a table and later an email can be randomly picked from the table as a winner for a free domain name.

Is there a way to display the current amount of emails in the table. Check the table to be sure that the email isnt already present. And pick a name at random?
__________________
DropLister is offline  
Old 06-29-2005, 08:03 PM   #2 (permalink)
Account Closed
 
axilant's Avatar
 
Join Date: May 2004
Location: /etc/passwd
Posts: 2,194
0.00 NP$ (Donate)

axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold


yes there is... :P ill gladly make the code for you for a few np$ :P
axilant is offline  
Old 06-29-2005, 08:11 PM   #3 (permalink)
NamePros Member
 
mixon's Avatar
 
Join Date: Jun 2005
Posts: 79
12.00 NP$ (Donate)

mixon is an unknown quantity at this point


such a commercial world we living in :-)

PMs sent, how it helped, I am going off!
mixon is offline  
Old 06-29-2005, 08:20 PM   #4 (permalink)
A Wealth of Knowledge
 
stscac's Avatar
 
Join Date: Aug 2004
Posts: 3,794
47.60 NP$ (Donate)

stscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud of


yeah droplister, i'll code it for you

-Steve
stscac is offline  
Old 06-29-2005, 10:41 PM   #5 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
to count the email address use count, to make sure you dont get the same emaill address twice in the table use unique for that field when creating the table.
Peter is offline  
Old 06-30-2005, 02:49 AM   #6 (permalink)
Senior Member
 
Porte's Avatar
 
Join Date: May 2005
Location: Somewhere on earth!
Posts: 3,528
21.30 NP$ (Donate)

Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of


Or:

let's say you setup the form <input type="text" size="25" name="email_addr">
when the page is submitted, you can check that email doesn't exist:

<?
$email_addr = $_POST['email_addr'];
$sql_emailchk = mysql_query("SELECT * FROM emails WHERE email_addr='$email_addr'");
$sql_result = mysql_num_rows($sql_emailchk);
if ($sql_result > 0) { // this means that email already exists
// show error or some page with error...
} else {
$sql_insert_email = mysql_query("INSERT INTO emails VALUES('', '$email_addr')");
}
?>

That was a basic function, now you make sure that email isn't duplicate of another.
To show total emails in your database, you can use count..and you can use

<?
$sql_getnum = mysql_query("SELECT * FROM emails");
$sql_num = mysql_num_rows($sql_getnum); // this will return number of rows
echo $sql_num; // should be some number...
?>

Well, basically, if you want to get one random result from your database/table, you could use something like RAND(); to randomize a result..
heres a tip:

Just call this function:
function GetRandomWinner() {
$sql_getrandom = mysql_query("SELECT * FROM emails ORDER BY RAND() LIMIT 0, 1");
$row = mysql_fetch_array($sql_getrandom);
extract($row);

echo 'Winning email: ';
echo $email_addr;
}

To call this function inside php, just use <? GetRandomWinner(); ?>

To get more than one winner randomly, increase the LIMIT 0, <b>1</b>

Not a complete code, but I hope it is helpful.
Porte is offline  
Old 06-30-2005, 07:37 AM   #7 (permalink)
Senior Member
 
Join Date: Apr 2005
Location: .ma.us
Posts: 1,783
21.95 NP$ (Donate)

DropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to beholdDropLister is a splendid one to behold

Baby Health Save a Life Save The Children
thanks designporte that helped alot
__________________
DropLister is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: Install the Apache Web Server, Perl, PHP, and MySQL on Windows deadserious Webmaster Tutorials 96 05-27-2007 01:24 PM
Tutorial: How to Install Apache2 MySQL and PHP on Windows deadserious Webmaster Tutorials 35 09-21-2005 09:46 PM
mysql problem Shof515 Programming 3 12-14-2004 09:20 PM
Tutorial: Getting Started With MySQL (The Basics) deadserious Webmaster Tutorials 3 04-18-2004 01:17 PM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 04:16 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85