| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 579
![]() ![]() | PHP loop Hey, Need a little help. Basically the following script should be checking the users credits and if they have more than 1, then display their link....But it doesn't. The script just takes forever to load. Then again I'm with Dreamhost and they're...well...awful. PHP Code:
__________________ SQL Dumpster - SQL Database Dumps and Resources |
| |
| | #3 (permalink) |
| Domains my Dominion Join Date: Aug 2005 Location: Web 1.0
Posts: 9,963
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Not sure about your purpose but you could do that in SQL Fetch one random record: ????: NamePros.com http://www.namepros.com/showthread.php?t=171485 PHP Code: For the updates you could do that in one shot too... using SQL again. I don't see the purpose of the PHP code here.
__________________ NameNewsletter.com - free lists of available domain names ZoneFiles.net (beta) - ccTLD and gTLD droplists |
| |
| | THREAD STARTER #4 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 579
![]() ![]() | well the active row is in the 'sites' table and the credits row is in the 'users' table
__________________ SQL Dumpster - SQL Database Dumps and Resources |
| |
| | #5 (permalink) |
| Domains my Dominion Join Date: Aug 2005 Location: Web 1.0
Posts: 9,963
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | You can do a join between the two tables: PHP Code:
__________________ NameNewsletter.com - free lists of available domain names ZoneFiles.net (beta) - ccTLD and gTLD droplists |
| |
| | THREAD STARTER #6 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 579
![]() ![]() | Thanks but how do I use that code to choose a random row?
__________________ SQL Dumpster - SQL Database Dumps and Resources |
| |
| | #7 (permalink) |
| Domains my Dominion Join Date: Aug 2005 Location: Web 1.0
Posts: 9,963
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Well you just add this at the end: ORDER BY RAND() LIMIT 1 ORDER BY RAND() means sort in random order and LIMIT 1 means limit the query to 1 record.
__________________ NameNewsletter.com - free lists of available domain names ZoneFiles.net (beta) - ccTLD and gTLD droplists |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Great Scripts for Sale With Resale Rights! | Zeeble | Scripts For Sale | 20 | 01-04-2006 01:39 AM |
| Googlism - What does google think of you? | deadserious | The Break Room | 55 | 12-15-2005 09:09 AM |