|
||||||
| PHP Tutorials PHP Tutorials |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
![]() First of all we must create tables to database: SQL Code:
Now we must start with our script.. PHP Code:
$SQLuser = ""; - your database username $SQLpass = ""; - your database password $DB = ""; - Database PHP Code:
mysql_select_db($DB) or die("Can not select database: ".mysql_error()); - It will select a database for you.. but if it can't select it will generate a detailed error ![]() Now let's find out how many banners we have in our database and let's generate a random number ![]() PHP Code:
$numTab = mysql_num_rows($query); - This will show us how many records are in our table Another 2 rows will generate a random number and they will select random banner. Now let's show our banner. PHP Code:
$banURL = $row['bannerurl']; - Banner's URL $banTXT = $row['bannertxt']; - Banner's text $Banner = $row['bannerimg']; - Banner itself $BanViews = $row['views']; - Banner's views $BanID = $row['id']; - Banner's ID echo"<a href='".$banURL."' target='_blank' title='".$banTXT."'><img src='".$banner."' alt='".$banTXT."' border='0'></a>"; - Shows the banner that was randomly chosen from the table $newViews = $BanViews+1; - Increases banner views by 1 mysql_query("UPDATE banner SET views = $newViews WHERE id = $BanID"); - Updates banner views And we are done Simple 'eh ![]() Okay here's the full script: PHP Code:
__________________
![]() CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | Freelance Cheap & Professional Web Design | Need help? Send a PM |
|
|||||
|
Makes sense to insert SQL code into the MySQL database, indeed.
__________________
Funny Stories and Humorous Pictures |
|
|||||
![]() mysql database isnt a file ![]() it's a database.. it's like server.. ![]()
__________________
![]() CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | Freelance Cheap & Professional Web Design | Need help? Send a PM |
|
|||||
|
you can use this function also if you have permission.. BUT usually you are not permitted to do it.. so.. you must create databases in your Cpanel or phpMyAdmin
__________________
![]() CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | Freelance Cheap & Professional Web Design | Need help? Send a PM |
|
|||||
|
hmm.. you gave me an idea.. i'll create some tutorials about that ![]()
__________________
![]() CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | Freelance Cheap & Professional Web Design | Need help? Send a PM |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Project: ionFiles - Joomla Simple File Download | Jordan | Community Projects | 360 | 05-23-2009 01:02 PM |
| Tutorial - A Simple Stropwatch! | travy92 | VB Tutorials | 19 | 05-04-2009 04:02 AM |
| A simple timer | travy92 | VB Tutorials | 1 | 02-18-2008 09:08 AM |
| implementing a simple database | martybell | Visual Basic Programming | 3 | 11-06-2007 04:25 PM |
| Banner ads | DevilsCharm | Marketing | 7 | 07-06-2006 11:33 AM |
Algorithms and Data Structures
Programming Language Popularity
Code Collaboration
Podnet IRC Network
AmpHosted
Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 55%, 75%