0

I'm an beginner in php/msql, and need help to solve this problem:

I have 4 items in my tabel, now I need to show those four items in order by ID. But now I want to add an Google Adsense banner between the second and third item. Which code should I use?

My page must look like this:

[ item 1 ] [ item 2 ] [ banner ] [ item 3 ] [ item 4 ]

My code:

function getenqeute(){
    $q = "SELECT * FROM tblenquetes ORDER BY id";
    $r = mysqli_query($dbc,$q);
    $amountenqeutes = mysqli_num_rows($r);
    $enqeutenow = 1;
    while($enquete = mysqli_fetch_array($r)){
        if($enqeutenow==$amountenqeutes){
            echo '';
        }else{
            echo '';
        }
        $desc = htmlentities(htmlspecialchars($enquete['enquetedescription']));
        $hash_tag = md5($enquete['enqueteid'] . date('d-m-Y H:i:s',time()));
        $date = date('Y-m-d', time());
        $q = "INSERT INTO tblcallback VALUES('', '".$_SERVER['REMOTE_ADDR']."', '".$hash_tag."', '".$date."', '".$enquete['enqueteid']."', '0')";
        mysqli_query($dbc, $q);

        $link = 'http://domain.nl/enquete?enq='.$enquete['enquetelink'].'&publ_tag='.$hash_tag;
        echo'
    <div class="enquete-item" onclick="location.href=\''.$link.'\';">
        <a rel="nofollow" href="'.$link.'">
            <img src="'.$enquete['enqueteimagelink'].'" alt="'.$enquete['enquetename'].'"></img>
        </a>
        <p><b><a rel="nofollow" href="'.$link.'">'.$enquete['enquetename'].'</a></b><br/>
        '.$desc.'</p>
        <div class="clear"></div>
    </div>';
        $enqeutenow++;
    }
}

Sorry for my bad English.

1
  • You really should separate your business logic from your presentation logic. May 14, 2012 at 16:24

1 Answer 1

3

Something like

if ($enqeutenow == 3)
    echo GoogleAd
2
  • I can try it, where i need to put this? (sorry, im not good in php)
    – Ibra038
    May 14, 2012 at 16:20
  • 1
    Anywhere before echoing the item, or after $enqeutenow++;, or use 2 instead of 3 just after echoing the item. May 14, 2012 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.