Jobs By Category:
.NET
3D Rendering
Academic Writing
Access DB
Accounting
Accounting/Bookkeeping
ActionScript
Active Directory
Adobe
Advertising
After Effects
Ajax
Algorithmic
Amazon Web Services
Android
Animation
Apache
Architecture
Art & Craft
Article
Article Rewriting
Article Submission
Articles
ASP
Asterisk PBX
Astroturfing
Auction
Audio Services
Audio Transcription
AutoCAD
Automotive
Azure
Banner Design
Biology
Biotechnology
Blackberry
Blog
Blog Install
Blog Posting
Boonex Dolphin
BPO
Branding
Building & Architecture
Building Architecture
Bulk Marketing
Business Analysis
Business Cards
Business Plans
Buyer Sourcing
C Programming
C#
C# Programming
C++ Programming
C/C++
CAD/CAM
CakePHP
Captivate
Caricature / Cartoons
Cartography/Maps
Catchy
Chemical Engineering
Christmas
Chrome OS
Cisco
Civil Engineering
Classifieds Posting
Clone
Cloud Computing/EC2
CMS
Cocoa
Codeigniter
Cold Fusion
Computer Security
Conceptual Design
Construction Monitoring
Contracts
Copywriting
Corporate Identity
Craigslist
CRM
Cryptography
CSS
Customer Support
Customization
Data
Data Entry
Data Processing
Data Scraping
Dating
Delphi
Desktop Support
Django
DNS
DotNetNuke
Dreamweaver
Drupal
E-Commerce
eBay
eBooks
eCommerce
Editing
Electrical Engineering
Electronic Forms
Electronics
Email
eMarketing
Embedded Software
Engineering
Erlang
ERP
Excel
Expression Engine
Facebook
Fashion Design
Fiction
Finance
Finance Research
Financial Markets
Finite Element Analysis
Fiverr
Flash
Flex
Forum
Forum Posting
Forum Software
Game Design
Genealogy
Geology
Ghostwriting
Google Analytics
Google App Engine
Google Go
Google Wave
GPGPU
Grant Writing
Graphic Design
Groupon
Handheld
Handheld / PDA
Home Design Drafting
HP Openview
HTML
Human Resources
IIS
Illustration
Illustrator
Image
InDesign
Industrial Design
Installation
Insurance
Interior Design
Internet Marketing
iPhone
iSeries / AS400
J2EE
Java
JavaFX
Javascript
Joomla
jQuery
jQuery / Prototype
JSP
LaTeX
Layout / Formatting
LDAP
Leads
Legal
Legal Advice
Legal Research
Link Building
LinkBuilding
Links
Linux
Logo Design
Long Term
Mac OS
MacOS
Magento
Magneto
Management
Manufacturing
Market Research
Marketing
Materials Engineering
Matlab/Mathematica
Maya
Mechanical Engineering
Mechatronics
Medical
Medical Writing
Metatrader
Microcontroller
Microsoft
MLM
MMORPG
MODx
MS Access
MS Exchange
MS Expression
MS SQL
MS Windows
mSQL
MSWindows
Multimedia
Music
MySpace
MySQL
Nokia
Objective C
Oracle
Order Processing
OsCommerce
Packaging / Covers
Palm
Patents
Paypal API
PCB Layout
PDF
Penny Auction
PeopleSoft
Perl
Perl/CGI
Phone Support
Photo
Photo Editing
Photography
Photoshop
Photoshop Coding
PHP
PLA / SCADA
PostgreSQL
Posting
Powerpoint
Presenter
Print
Printing
Product Descriptions
Product Sourcing
Programming
Project Management
Project Scheduling
Proofreading
Protoshare
PSD Coding
PSD to HTML
PSD2CMS
Publishing
Python
Quantum
Quantum Computing/Physics
QuarkXPress
Quickbooks/Quicken/MYOB
REALbasic
Recruiting
Rendering/3D
Report Writing
Research
Reviews
Ruby/Ruby on Rails
Sales
SAP
Scientific Research
Script Install
Script Installation
Search Engine Optimization
Second Life / Virtual Worlds
Security
SEM / Adwords
SEO
Sharepoint
Shell Script
Shopping Carts
Silverlight
Slideshow
Social Engine
Social Networking
SocialEngine
Software Architecture
Software Testing
Solidworks
Sports
SQL
Stationery Design
Statistical Analysis
Structural Engineering
Supplier Sourcing
Support
Symbian
System Admin
System Admin.
System Administration
Tax
Technical Support
Technical Writing
Telemarketing
Template
Templates
Test Automation
Testing / QA
Training
Transcription
Translation
Travel Writing
Troubleshooting
Tutoring
Tutoring / Education
Twitter
Typography
UML Design
User Interface / IA
vBulletin
Verilog / VHDL
Video Broadcasting
Video Services
Video Uploading
Virtual Assistant
Virtual Reality
Visio
Visual Basic
Voice Talent
VoIP
Volusion
Web Promotion
Web Scraping
Web Search
Website
Website Design
Website QA
Website Security
Weddings
Windows
Windows Mobile
Windows Server
Wireless
Word
Wordpress
Writing
XHTML
XML
XXX
YouTube
Zen Cart
Zend


Thousands of experts bid on your personal project at ScriptLance.com

Mysql Php Pagination Fix


Required knowledge: PHP, MySQL







Hello,




I have a script, it displays all active banners using pagination. Once the banner is clicked it doesn't show up again. This works fine.




The issue:




For example I'm displaying 25 banners per page, I have over 1000 active banners so there are 102 pages.




If I click on the all 25 of the banners on page one and then leave the site, the next time I come back to the site they do not show. This works correctly. But here is the problem, when I come back to the site page one is blank, I have to move on to page 2 in order to see the next round of banners. So in other words it's not moving the banners up to page one.




I need this fixed.




Here is the code if you think you want to tackle it.




[code]


<?php








session_start();








include "../header.php";




include "../config.php";




include "../style.php";


$ uname=$ _SESSION[uname];


if( session_is_registered("ulogin") ) {












$ tbl_name="banners"; //your table name




// How many adjacent pages should be shown on each side?




$ adjacents = 3;









/*




First get total number of rows in data table.




If you have a WHERE clause in your query, make sure you mirror it here.




*/




if( session_is_registered("ulogin") )




{




$ query = "SELECT COUNT(*) as num FROM banners, banner_clicks WHERE banners.status=1 and banners.max>banners.shown AND banner_clicks.userid<>'".userid."' group by banners.id";




}




else




$ query = "SELECT COUNT(*) as num FROM $ tbl_name WHERE status=1 and max>shown";




$ ttlpag=mysql_query($ query) or die (mysql_error());




$ total_pages = mysql_fetch_array($ ttlpag);




$ total_pages = $ total_pages[num];


$ qn="select * from sat_banclicks where userid='$ uname' group by bannerid";


$ ns=mysql_query($ qn);


$ nk=mysql_num_rows($ ns);


$ total_pages=$ total_pages-(2*$ nk);


//echo $ nk;







/* Setup vars for query. */




$ targetpage = "bannerlinkview.php"; //your file name (the name of this file)




$ limit = 25; //how many items to show per page




$ page = $ _GET['page'];




if($ page)




$ start = ($ page - 1) * $ limit; //first item to display on this page




else




$ start = 1; //if no page var is given, set start to 0














/* Get data. */




if( session_is_registered("ulogin") )




{




$ sql = "SELECT banners.id as id, banners.name as name, banners.bannerurl as bannerurl, banners.targeturl as targeturl, banners.userid as userid, banners.shown as shown, banners.clicks as clicks, banners.max as max, banners.added as added FROM banners, banner_clicks WHERE banners.status=1 and banners.max>banners.shown AND banner_clicks.userid<>'".userid."' group by banners.id LIMIT $ start, $ limit";




}




else




{




$ sql = "SELECT * FROM banners WHERE status=1 and max>shown LIMIT $ start, $ limit";




}









$ result = mysql_query($ sql) or die (mysql_error());








if(!mysql_num_rows($ result))




{




$ result = mysql_query ("SELECT * FROM banners WHERE status=1 and max>shown LIMIT $ start, $ limit");




}
















/* Setup page vars for display. */




if ($ page == 0) $ page = 1; //if no page var is given, default to 1.




$ prev = $ page - 1; //previous page is page - 1




$ next = $ page + 1; //next page is page + 1




$ lastpage = ceil($ total_pages/$ limit); //lastpage is = total pages / items per page, rounded up.




$ lpm1 = $ lastpage - 1; //last page minus 1









/*




Now we apply our rules and draw the pagination object.




We're actually saving the code to a variable in case we want to draw it more than once.




*/




$ pagination = "";




if($ lastpage > 1)




{


























$ pagination .= "<div class="pagination">";




//previous button




if ($ page > 1)




$ pagination.= "<a href="$ targetpage?page=$ prev">« previous</a>";




else




$ pagination.= "<span class="disabled">« previous</span>";









//pages




if ($ lastpage < 7 + ($ adjacents * 2)) //not enough pages to bother breaking it up




{




for ($ counter = 1; $ counter <= $ lastpage; $ counter++)




{




if ($ counter == $ page)




$ pagination.= "<span class="current">$ counter</span>";




else




$ pagination.= "<a href="$ targetpage?page=$ counter">$ counter</a>";




}




}




elseif($ lastpage > 5 + ($ adjacents * 2)) //enough pages to hide some




{




//close to beginning; only hide later pages




if($ page < 1 + ($ adjacents * 2))




{




for ($ counter = 1; $ counter < 4 + ($ adjacents * 2); $ counter++)




{




if ($ counter == $ page)




$ pagination.= "<span class="current">$ counter</span>";




else




$ pagination.= "<a href="$ targetpage?page=$ counter">$ counter</a>";




}




$ pagination.= "...";




$ pagination.= "<a href="$ targetpage?page=$ lpm1">$ lpm1</a>";




$ pagination.= "<a href="$ targetpage?page=$ lastpage">$ lastpage</a>";




}




//in middle; hide some front and some back




elseif($ lastpage - ($ adjacents * 2) > $ page && $ page > ($ adjacents * 2))




{




$ pagination.= "<a href="$ targetpage?page=1">1</a>";




$ pagination.= "<a href="$ targetpage?page=2">2</a>";




$ pagination.= "...";




for ($ counter = $ page - $ adjacents; $ counter <= $ page + $ adjacents; $ counter++)




{




if ($ counter == $ page)




$ pagination.= "<span class="current">$ counter</span>";




else




$ pagination.= "<a href="$ targetpage?page=$ counter">$ counter</a>";




}




$ pagination.= "...";




$ pagination.= "<a href="$ targetpage?page=$ lpm1">$ lpm1</a>";




$ pagination.= "<a href="$ targetpage?page=$ lastpage">$ lastpage</a>";




}




//close to end; only hide early pages




else




{




$ pagination.= "<a href="$ targetpage?page=1">1</a>";




$ pagination.= "<a href="$ targetpage?page=2">2</a>";




$ pagination.= "...";




for ($ counter = $ lastpage - (2 + ($ adjacents * 2)); $ counter <= $ lastpage; $ counter++)




{




if ($ counter == $ page)




$ pagination.= "<span class="current">$ counter</span>";




else




$ pagination.= "<a href="$ targetpage?page=$ counter">$ counter</a>";




}




}




}









//next button




if ($ page < $ counter - 1)




$ pagination.= "<a href="$ targetpage?page=$ next">next »</a>";




else




$ pagination.= "<span class="disabled">next »</span>";




$ pagination.= "</div>
";




}



























include("navigation.php");




include("../banners.php");









echo "<font size=2 face='$ fonttype' color='$ fontcolour'><p><center>";




echo "<center><p><b>";




echo "</center></p></b>";




//mysql_close($ dblink);




?>




<table align=center><tr><td><?=$ pagination?></td></tr></table>




<table width=80% border=0 cellpadding=2 cellspacing=2> <?




while ($ line = mysql_fetch_array($ result)) {




$ id = $ line["id"];




$ userid = $ line["userid"];




$ targeturl = $ line["targeturl"];




$ bannerurl = $ line["bannerurl"];




$ qur_mod="select * form banner_clicks where bannerid='$ id' and userid='$ userid' and status='1'";


//echo $ userid;


$ qur_res=mysql_query("select * from sat_banclicks where bannerid='$ id' and userid='$ uname' and status='1' limit 1") or die ("error: ".mysql_error());


$ num_disp=mysql_num_rows($ qur_res);


//echo $ num_disp;


if ($ num_disp>0)


{


}


else


{


?>




<tr>


<td bgcolor="<? echo $ basecolour; ?>"><font size=2 face="<? echo $ fonttype; ?>" color="<? echo $ fontcolour; ?>"><center><a href="bannerclick.php?id=<? echo $ id; ?>" target="_blank"><img src="<? echo $ bannerurl; ?>"></a></font></center></td></tr>


</td></tr>


<tr>




<td> </td>








</tr>












<?


}


}


mysql_close($ dblink);




echo "</table></center>" ;




echo "</td></tr></table>";




}




else




echo "Unauthorised Access!";




?>




<table align=center><tr><td><?=$ pagination?></td></tr></table>




<?




include "../footer.php";








?>


[/code]








Job Categories:

PHP

MySQL

Related projects:

Quick fix to PHP/MySQL search   Featured Projects, identified by a label, attra

ascript"> var protocol = ('https:' == document.location.protocol ? 'https' : 'http'); document.write(''); OX.addVariable('job_type', '-MySQL-PHP-Website-Design/">Website Design-'); OX.requestAd({"auid":"31792"});

Fix Mysql Php Error Mysql_numrows

eturned or $ cnt < 5 , the query is run again this time with locexact = 0.
If there are still no results, then echo "No Results." If there are results, echo the results with locexact = 1 on top and locexact = 0 on bottom. I want the combined results limit still at 5.
See attachment for full file. Also with this project, I don't want to give ftp access. This code should not be that hard to fix/modify for an experienced php/mysql programmer.
Thanks.

PHP + MySQL + Smarty - Pagination needed - URGENT  

are more to come.

Bug fix on PHP/MySQL site  

hich a user selects a country from a drop down, upon selecting a country Ajax is used to populate the states drop down box.
The drop down for the states is not being populated. I need this fixed.
**I need this done TODAY** Shouldn't take more than an hour
I have come across some Mickey Mouse developers through Freelance.com and also some great developers, if your a Mickey Mouse developer please don't bid, you'll only waste my time.

Some PHP bugs fix

erver, but I can't do it.
I am using same code and php file ( I changed ID /PW for another database, it is correct).
New server is below, and PHP and MySQL are installed.
http://www.monthly-osaka.com/test/map.html
That's all. For our company's security policy, you can't login our FTP server.
To fix these bugs, you need to try and test them in your server.
(of course, I will send you all files you need)

MySQL/PHP Optimization and fix errors

QL based on Linux, and Website-Design/">Website Design.
1. You would have to do site speed optimization and check that is wrong with the site.
2. Optimize our database to perform efficiently without using much resources.
3. Fix all bugs/errors so the website can function normally between 2-3 seconds.
More information about the website will be provided upon talking to you one on one.
Budget for this project is from $ 100-$ 150

FINISH PHP MYSQL PROJECT  

xt/javascript"> var protocol = ('https:' == document.location.protocol ? 'https' : 'http'); document.write(''); OX.addVariable('job_type', '-AJAX-CSS-MySQL-PHP-'); OX.requestAd({"auid":"31792"});

Fix php on 3 instances of 1 custom Wordpress Search Forms  

ipt"> var protocol = ('https:' == document.location.protocol ? 'https' : 'http'); document.write(''); OX.addVariable('job_type', '-MySQL-PHP-SQL-Wordpress/">Wordpress-Zend-'); OX.requestAd({"auid":"31792"});

Finish up a PHP/MySQL dating site  

xt/javascript"> var protocol = ('https:' == document.location.protocol ? 'https' : 'http'); document.write(''); OX.addVariable('job_type', '-CSS-HTML-MySQL-PHP-'); OX.requestAd({"auid":"31792"});

PHP/Mysql programmer   Featured Projects, identified by a label, attract more b

t/javascript"> var protocol = ('https:' == document.location.protocol ? 'https' : 'http'); document.write(''); OX.addVariable('job_type', '-AJAX-HTML-MySQL-PHP-'); OX.requestAd({"auid":"31792"});

Php & Mysql Programmer for immediate help  

script"> var protocol = ('https:' == document.location.protocol ? 'https' : 'http'); document.write(''); OX.addVariable('job_type', '-AJAX-MySQL-PHP-Smarty PHP-'); OX.requestAd({"auid":"31792"});

XOOPS project: Add Google GeoAPI & Create PHP XML from MySQL  

t/javascript"> var protocol = ('https:' == document.location.protocol ? 'https' : 'http'); document.write(''); OX.addVariable('job_type', '-Linux-MySQL-PHP-XML-'); OX.requestAd({"auid":"31792"});

Fix Issues and enhance the existing script in PHP  

var protocol = ('https:' == document.location.protocol ? 'https' : 'http'); document.write(''); OX.addVariable('job_type', '-AJAX-Graphic Design-Javascript-MySQL-PHP-'); OX.requestAd({"auid":"31792"});

Vtiger PHP fix  

text/javascript"> var protocol = ('https:' == document.location.protocol ? 'https' : 'http'); document.write(''); OX.addVariable('job_type', '-MySQL-PHP-vTiger-'); OX.requestAd({"auid":"31792"});

Php, Mysql, Flash Chat Editor needed asap  

var protocol = ('https:' == document.location.protocol ? 'https' : 'http'); document.write(''); OX.addVariable('job_type', '-MySQL-PHP-Plesk-Software Architecture-'); OX.requestAd({"auid":"31792"});

.Htaccess + PHP professional, fix infinite loop and more  

rience. Thanks.

Update Traffic Exchange Code To Newer Mysql/php

ing and we will work with coder to guide them to help convert all code.
Must be able to work a few hours daily live with use to show and give feedback and testing of any new code changes.
Interested coder should only reply if they have full knowledge of working with other Traffic Exchange Surfing and only if you agree to work with us on our script and server and be able to work daily via live chat, reply and post the the word "Skype Me" in the PM or message reply.

PHP / MySQL Expert to fix Websites Crawler - Start Now!  

x budget $ 50=====

PHP / MySQL Expert to fix Websites Crawler - Start Now !!  

x budget $ 50=====

Nutrition Database Mysql/php

then let me graph the results using this graph company http://www.highcharts.com/demo/
I have attached a detailed PDF of the job I need. Please review. I really need a programmer that is reliable, fast, responds daily with updates and will start right away.

Post your own project on getafreelancer Search for scimilar work on getafreelancer
Post your own project on scriptlance Search for scimilar work on scriptlance
Post your own project on eufreelance Search for scimilar work on eufreelance

Post and Bid on projects! Join EUFreelance.com for free!

Get custom programming done at GetAFreelancer.com!




Currently viewed: "Mysql Php Pagination Fix"