NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page MYsql

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

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 06-29-2005, 08:14 PM THREAD STARTER               #1 (permalink)
Senior Member

Join Date: Apr 2005
Location: .ma.us
Posts: 1,880
DropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud of
 


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, 09:03 PM   #2 (permalink)
Account Closed
 
axilant's Avatar
Join Date: May 2004
Location: /etc/passwd
Posts: 2,178
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
 

Member of the Month
July 2005

yes there is... ill gladly make the code for you for a few np$
axilant is offline  
Old 06-29-2005, 09:11 PM   #3 (permalink)
NamePros Member
 
mixon's Avatar
Join Date: Jun 2005
Posts: 79
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, 09:20 PM   #4 (permalink)
A Wealth of Knowledge
 
stscac's Avatar
Join Date: Aug 2004
Posts: 3,809
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, 11:41 PM   #5 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
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, 03:49 AM   #6 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
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')");
????: NamePros.com http://www.namepros.com/programming/102925-mysql.html
}
?>

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, 08:37 AM THREAD STARTER               #7 (permalink)
Senior Member

Join Date: Apr 2005
Location: .ma.us
Posts: 1,880
DropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud ofDropLister has much to be proud of
 


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


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 02:24 PM
Tutorial: How to Install Apache2 MySQL and PHP on Windows deadserious Webmaster Tutorials 35 09-21-2005 10:46 PM
mysql problem Shof515 Programming 3 12-14-2004 10:20 PM
Tutorial: Getting Started With MySQL (The Basics) deadserious Webmaster Tutorials 3 04-18-2004 02:17 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:42 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger