viperviper9 Posted July 28, 2007 Share Posted July 28, 2007 I want to insert a banner between my search results, so how to do that? this is the code iam using right now. $i=0; echo"<table align= 'center' border='0' width = '85%'id='table14' style='border-collapse: collapse'>"; while($row = mysql_fetch_array($sql)){ echo "<td align='center' bgcolor='#F1F1F1' bordercolor='#4D4D4D' style='border: 1px solid #F1F1F1' width= '400' height= '130'>"; echo "<font face=Arial size=1 color=#000000>"; //echo "<B>"; echo " $row[Make]"; echo " -"; echo " $row[Model]"; /*code to mark car sold*/ if($row[sold]==Yes) { echo"<center>"; echo "<img src=../../images/CarImg/"; echo "$row[Ref]S.JPG"; echo " width=120 height=80 border=0>"; echo "<span style=position: absolute; valign=middle; align=center><img border=0 src=images/sold.gif width=20 height=80></span>"; echo"</center>"; } else { echo "<A HREF=\"detail.php?ref=$row[Ref]\" target=\"_blank\" alt=\"Click for more Info\">"; echo "<br><img src=../../images/CarImg/"; echo "$row[Ref]S.JPG"; echo " width=120 height=80 border=0 ALT='Call Me.. $row[Contact]'></img></br>"; echo"</center></a>"; } echo "$row[Year]"; if($row[Price]=="") echo ""; else echo " - BD $row[Price]"; echo "</B>"; echo " </font>"; echo "</a></td>"; $i++ ; if ($i == 3) { echo "<tr>"; $i=0; } } so please can you help me with that thanks Quote Link to comment Share on other sites More sharing options...
MatMel Posted July 28, 2007 Share Posted July 28, 2007 Erm, what exactly is you problem? You just have to echo the HTML-Code for the banner at each loop ... Quote Link to comment Share on other sites More sharing options...
viperviper9 Posted July 28, 2007 Author Share Posted July 28, 2007 thanks for your reply my problem is : I have a cars website and what I need to do is when I do search for cars, on each page I set 21 cars to show on it and on each row 3 cars, so now I want to show a banner after 6 cars or after two rows. this my website page: http://www.bahcars.com/en/FindACar.php?brand=&model=&Year=All+Years&Price=&doSearch=Search thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted July 31, 2007 Share Posted July 31, 2007 Well, just keep a counter... Quote Link to comment Share on other sites More sharing options...
viperviper9 Posted August 4, 2007 Author Share Posted August 4, 2007 Hi fenway thanks for your reply , in fact I tried with your suggestion ( using counter ) but with no luck , maybe I did not do it in the right way becouse I am not that well in php , and this is the first time I use counter , any way thanks for your help. if you have any idea how to do it tell me about it. thanks best regards Quote Link to comment Share on other sites More sharing options...
dcp Posted August 7, 2007 Share Posted August 7, 2007 That you reset your counter whenever it gets to 3 presents a bit of a problem if you want to get to six, but you could initialize another counter at the same time, say: $i=0; $n=0; echo"<table align= 'center' border='0' width = '85%'id='table14' style='border-collapse: collapse'>"; while($row = mysql_fetch_array($sql)){ // I think you need this <tr> in here, and the line break, \n, will make the html output easier read. I'd add it it to every line echo "<tr>\n"; //then back to your code: echo "<td align='center' bgcolor='#F1F1F1'. . . //do consider putting some of this style stuff in your css . . . then below where you increment: $i++ ; //increment the new one, as well $n++; if ($i == 3) { echo "</tr>\n"; // check to see if the new variable, $n, is evenly divisible by six using modulus operator. If so, add a row with the banner. if ($n % 6 == 0) { echo "<tr><td colspan=\"3\"><img src=\"bannerimage.jpg\" /></td>\n</tr>\n"; } $i=0; } . . . I might consider initializing $i as "1" rather than "0" (and making appropriate changes in the rest of the code) just because its easier for me that way. Quote Link to comment Share on other sites More sharing options...
viperviper9 Posted August 9, 2007 Author Share Posted August 9, 2007 To everyone I am really would like to thanks everyone helped me with that problem , it was a nightmare for me , but really really thanks to you .. thank you dcp & fenway and MatMel viperviper9 best regards Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.