rhock_95 Posted June 11, 2008 Share Posted June 11, 2008 I'm thinking this can be done script-side rather than in the database itself... here's what I need help with...I have a script that displays a list of contacts when a category is selected...the results are displayed in a list with pagination ... a typical row (display code) looks like this: echo ' <td>'.$data['phone'].' </td>'; What I would like to do is is have a "Google AdSense" text ad be displayed after X amount of displayed rows...can I use php to include() the Adsense code in this manner?...If this is possible, can someone post an example of how the display counts the rows and includes the ad file. Link to comment Share on other sites More sharing options...
hansford Posted June 11, 2008 Share Posted June 11, 2008 $ad_display_every = 6; $count = 1; while($data = mysql_fetch_array($result)){ echo ' <td>'.$data['phone'].' </td>'; if($count == $ad_display_every){ //add google code here $count = 1; } else{ $count++; } } Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 thanks for the reply...I will check it out... Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 sorry no joy... I had to remove the final curly bracket...after that zero errors but no joy either... exactly what format/syntax should the "google code" be in ? thanks again or anyone that can help... Link to comment Share on other sites More sharing options...
hansford Posted June 11, 2008 Share Posted June 11, 2008 I don't know how your code is setup-my code was an example of how to do it. If you remove the last curly brace from my example you don't close out the while loop. As far as google is concerned I know nothing but, you have to sign up for it and then you can get code to embed. Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 just say I wanted to display plain text...what would be the syntax ? TIA Link to comment Share on other sites More sharing options...
hansford Posted June 11, 2008 Share Posted June 11, 2008 echo 'here is some plain text where the google code would be'; Link to comment Share on other sites More sharing options...
.josh Posted June 11, 2008 Share Posted June 11, 2008 $y = 5; // number of rows to display per text $text = "blahblahblah<br />"; // text to display // example loop for ($x = 0; $x < 100; $x++) { echo (($x % $y) == 0)? $text : ""; echo "$x <br />"; } Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 is this something to be used on it's own or in conjunction with the previous replies? sorry I have no idea how to implement this with my script...I am not a php coder...just a poor site admin trying to pay for gasoline... Link to comment Share on other sites More sharing options...
.josh Posted June 11, 2008 Share Posted June 11, 2008 that's an example of how to get something to display every 5 lines. You would have to integrate that principle into your own code, yes. Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 if you want to help me I supplied a line of my display code in the OP...if you do not wish to actually help me just say so... Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 neither of the posted snippets work... here is an example of what the latter displays: blahblahblah 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 blahblahblah 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 blahblahblah can anyone help me with this...? Link to comment Share on other sites More sharing options...
DarkWater Posted June 11, 2008 Share Posted June 11, 2008 Okay, look. We aren't going to code it for you. If you want that, go to the Freelance forums. Otherwise, learn a bit of PHP and give us more code to work with so we can HELP you, not DO IT FOR YOU. Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 I am not a php coder but I am a decent php hack...what other code would you need? Link to comment Share on other sites More sharing options...
DarkWater Posted June 11, 2008 Share Posted June 11, 2008 I am not a php coder but I am a decent php hack...what other code would you need? How about the AdSense code? How about the rest of the code that you use to make up your loop so we can see how you're getting the data? Link to comment Share on other sites More sharing options...
.josh Posted June 11, 2008 Share Posted June 11, 2008 What I would like to do is is have a "Google AdSense" text ad be displayed after X amount of displayed rows...can I use php to include() the Adsense code in this manner?...If this is possible, can someone post an example of how the display counts the rows and includes the ad file. if you want to help me I supplied a line of my display code in the OP...if you do not wish to actually help me just say so... I gave you an example loop that displays something after X amount of displayed rows, just like you asked for. No offense, but if you can't make sense of a simple condition inside a simple loop, then maybe you aren't the decent php hack you say you are. There really isn't anything more we can do for you, short of doing your work for you, which is something we don't do. People do that sort of thing for money. Link to comment Share on other sites More sharing options...
DarkWater Posted June 11, 2008 Share Posted June 11, 2008 Yeah, this is not where we code for you. I'd be happy to code it for you if you'd be happy to pull out your credit card. Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 you don't really need the adSense code...plain text will work as an example... as for the loop..the script just displays a list of results through a pagination function... how can I make it display "plain text" every 15 rows or so? Link to comment Share on other sites More sharing options...
.josh Posted June 11, 2008 Share Posted June 11, 2008 you don't really need the adSense code...plain text will work as an example... as for the loop..the script just displays a list of results through a pagination function... how can I make it display "plain text" every 15 rows or so? You make a loop with a condition in it. Or you put a condition in your existing loop. You know, like the example I already showed you. Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 your example did not work ...duh! Link to comment Share on other sites More sharing options...
.josh Posted June 11, 2008 Share Posted June 11, 2008 You asked for some thing to be displayed every X amount of rows. That's what my script did. You even posted the output. So either you aren't being clear about what you want or... Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 what I asked for was a snippet (not a whole freakin script) that would display something every x amount of rows OF THE EXAMPLE I POSTED not a list of freakin integers...duh! Link to comment Share on other sites More sharing options...
DarkWater Posted June 11, 2008 Share Posted June 11, 2008 You sound like a bratty, demanding two year old. I'd be shocked if anyone wants to help you now. I certainly don't. Link to comment Share on other sites More sharing options...
rhock_95 Posted June 11, 2008 Author Share Posted June 11, 2008 you holier than thou types are all alike you're the bratty sounding ones...all I asked for was something that would actually help me...not give you a chance to play the school marm... thanks for nothing as obviously your examples don't work when applied... FYI...not everyone has the time or the budget to learn themselves or to hire a coder to just make a change to an existing script... Link to comment Share on other sites More sharing options...
.josh Posted June 11, 2008 Share Posted June 11, 2008 Okay seriously man, you're starting to get out of line. You have been given 2 examples of how to condition a loop to display something every X lines, just like you asked for. They spit out numbers because they are example scripts, meant to display the principle for what you are asking for. You have to take that principle and apply it to your own script. You asked for how to do something, and you were given examples that do exactly what you asked for. It seems pretty obvious to me that you simply don't grasp the concept of applying the principle of one piece of code to another, and that's fine. I'm not judging. But you need to make a much more concerted effort on your part if you wish to get anywhere with your code. Yelling and screaming at us saying that we aren't being helpful just because you can't take the example, copy and paste it into your script and it magically works, is not making a concerted effort. I am closing your thread, as your question has been answered. I'm sorry that you don't understand it, but it has been answered, nonetheless. Instead of being grateful to those who have helped on their own free time, you've been rude and snippy and lazy. Link to comment Share on other sites More sharing options...
Recommended Posts