Jump to content

[SOLVED] adding banner between my search results


viperviper9

Recommended Posts

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

 

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.