Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Inserting advertising between rows
Old 03-15-2008, 07:38 AM Inserting advertising between rows
Skilled Talker

Posts: 69
Trades: 0
Hi, I have a bit of a conundrum. I am trying to get my site page to look like this:

First 5 rows
(advertisment)
Next 10 rows
(advertisment)

Can anyone advise the easiest (least code required) way to achieve this? I tried to use row-id but I have multiple row categories so the id is not consistent (eg. it might go 6,7,43,2,18 etc. which is where I got stuck). I'm wondering how I can get it to count the rows as the number the query has outputted so far instead of the db id's...
alexd181 is offline
Reply With Quote
View Public Profile Visit alexd181's homepage!
 
 
Register now for full access!
Old 03-16-2008, 07:37 AM Re: Inserting advertising between rows
Skilled Talker

Posts: 69
Trades: 0
Nvm, I got it working by declaring an int variable outside the repeat region loop and getting it to increment by 1 inside the repeat region loop and then put the ad in the repeat region loop for conditions if counter1 = 5 or 15 etc.
alexd181 is offline
Reply With Quote
View Public Profile Visit alexd181's homepage!
 
Old 03-16-2008, 08:08 AM Re: Inserting advertising between rows
Novice Talker

Posts: 5
Trades: 0
if you had to add a bunch of conditions like...

if($i == 5 || $i == 10 || $i ==15 || ... || $i == 50000000) .....

you need to use 'mod'

if($i % 5 == 0)

If you are unfamiliar... it means if $i divided by 5 returns a remainder of zero (ie is divisible by 5) then execute..
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
psychdev is offline
Reply With Quote
View Public Profile
 
Old 03-16-2008, 09:14 AM Re: Inserting advertising between rows
Skilled Talker

Posts: 69
Trades: 0
Quote:
Originally Posted by psychdev View Post
if you had to add a bunch of conditions like...

if($i == 5 || $i == 10 || $i ==15 || ... || $i == 50000000) .....

you need to use 'mod'

if($i % 5 == 0)

If you are unfamiliar... it means if $i divided by 5 returns a remainder of zero (ie is divisible by 5) then execute..
Why do I need to use mod? The first line above does it. mod seems superfluous
alexd181 is offline
Reply With Quote
View Public Profile Visit alexd181's homepage!
 
Old 03-16-2008, 07:32 PM Re: Inserting advertising between rows
Novice Talker

Posts: 5
Trades: 0
you don't need to use mod.. but if you have a dynamic data driven site... auto-generating the rows, you need to use mod.

What I mean is.. if your site visitors are generating the rows... you could end up with more rows than you are anticipating. mod works to infinity. If you yourself are generating the rows simply with your code, then don't worry about changing your code
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
psychdev is offline
Reply With Quote
View Public Profile
 
Old 03-16-2008, 08:44 PM Re: Inserting advertising between rows
Skilled Talker

Posts: 69
Trades: 0
The only difference is that if I use if($i == 5 || $i == 14 || $i ==17 || ... I can have different intervals I want, but if I were to use if($i % 5 == 0) then that would display every 5 rows, is that correct?
alexd181 is offline
Reply With Quote
View Public Profile Visit alexd181's homepage!
 
Reply     « Reply to Inserting advertising between rows
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16488 seconds with 12 queries