Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
Wechat qr verification
Pawan2005
Updated:
Today at 1:28 AM
🚀 GOOGLE AI PRO 18 MONTHS ACTIVATION 🚀
sayuru bandara
Updated:
Yesterday at 5:34 PM
Pure VPN - Up to 27 Months
vgp
Updated:
Friday at 8:10 AM
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Jun 2, 2026
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
May 30, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
php mysqli
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="jayampathi" data-source="post: 19839224" data-attributes="member: 470"><p>machan mata podi script ekak hamba una</p><p> mata one data insert karanna</p><p></p><p>html form ekain data mysqli walata yana widihata</p><p>mata poddak karana widiha kiyanna</p><p></p><p>DB</p><p></p><p>CREATE TABLE `banners` (</p><p> `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,</p><p> `url` VARCHAR( 150 ) NOT NULL ,</p><p> `banner` VARCHAR( 150 ) NOT NULL ,</p><p> `name` VARCHAR( 60 ) NOT NULL, 'clicks' INT NOT NULL DEFAULT '0'</p><p>) ;</p><p></p><p></p><p>conection</p><p><?php $db_host = "localhost";</p><p>$db_username = "root";</p><p>$db_password = "";</p><p>$db_database = "counter";</p><p></p><p>$link = mysqli_connect($db_host,$db_username,$db_password) or die("Cannot connect");</p><p>mysqli_select_db($link, $db_database) or die("Cannot select the database"); ?></p><p></p><p>index </p><p><?php</p><p>include("config.php");</p><p>$sql = mysqli_query($link, "SELECT id, url, banner, name FROM banner");</p><p> ?></p><p> </p><p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></p><p> <html xmlns="http://www.w3.org/1999/xhtml"></p><p> <head></p><p> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></p><p> <title>banners index page</title></p><p> </head></p><p><body></p><p><div id="container"></p><p><?php</p><p>while($result = mysqli_fetch_object($sql)):</p><p> ?></p><p> <p></p><p> <a href="counter.php?id=<?php echo $result->id; ?>"></p><p> <img src="<?php echo $result->banner; ?>" alt="<?php echo $result->name; ?>" /></p><p> </a></p><p> </p></p><p> <?php</p><p>endwhile;</p><p>?></p><p></div><!-- end of container --></p><p></body></p><p></html></p><p></p><p></p><p>count</p><p><?php</p><p></p><p>//1. include the configuration file</p><p> include("config.php");</p><p></p><p>//2. Get the id from the url and store it into a variable</p><p> $id = mysqli_real_escape_string($link, $_GET['id']);</p><p></p><p>//3. fetch the url and clicks from this banner</p><p> $clicks = mysqli_fetch_object(mysqli_query($link, "SELECT url, clicks FROM banners WHERE id=".$id.""));</p><p></p><p>//4. increase clicks with 1</p><p> $new_click = $clicks->clicks+1;</p><p></p><p>//5. update this into the database, check if it was succesfull</p><p> if(mysqli_query($link, "UPDATE banners SET clicks=".$new_click." WHERE id=".$id."")):</p><p> //6. redirect to the url</p><p> header("Location: ".$clicks->url);</p><p> else:</p><p> //6. else write to error log</p><p> endif;</p><p>?></p></blockquote><p></p>
[QUOTE="jayampathi, post: 19839224, member: 470"] machan mata podi script ekak hamba una mata one data insert karanna html form ekain data mysqli walata yana widihata mata poddak karana widiha kiyanna DB CREATE TABLE `banners` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `url` VARCHAR( 150 ) NOT NULL , `banner` VARCHAR( 150 ) NOT NULL , `name` VARCHAR( 60 ) NOT NULL, 'clicks' INT NOT NULL DEFAULT '0' ) ; conection <?php $db_host = "localhost"; $db_username = "root"; $db_password = ""; $db_database = "counter"; $link = mysqli_connect($db_host,$db_username,$db_password) or die("Cannot connect"); mysqli_select_db($link, $db_database) or die("Cannot select the database"); ?> index <?php include("config.php"); $sql = mysqli_query($link, "SELECT id, url, banner, name FROM banner"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>banners index page</title> </head> <body> <div id="container"> <?php while($result = mysqli_fetch_object($sql)): ?> <p> <a href="counter.php?id=<?php echo $result->id; ?>"> <img src="<?php echo $result->banner; ?>" alt="<?php echo $result->name; ?>" /> </a> </p> <?php endwhile; ?> </div><!-- end of container --> </body> </html> count <?php //1. include the configuration file include("config.php"); //2. Get the id from the url and store it into a variable $id = mysqli_real_escape_string($link, $_GET['id']); //3. fetch the url and clicks from this banner $clicks = mysqli_fetch_object(mysqli_query($link, "SELECT url, clicks FROM banners WHERE id=".$id."")); //4. increase clicks with 1 $new_click = $clicks->clicks+1; //5. update this into the database, check if it was succesfull if(mysqli_query($link, "UPDATE banners SET clicks=".$new_click." WHERE id=".$id."")): //6. redirect to the url header("Location: ".$clicks->url); else: //6. else write to error log endif; ?> [/QUOTE]
Insert quotes…
Verification
Payakata winadi keeyak tibeda?
Post reply
Top
Bottom