Jump to content

Snippet


sessions

Recommended Posts

I have a webpage (www.spraypickle.com). Where it says new, I want a banner (an ad) to float directly above the text, even after I add content to it.

 

This is the index page. I want to insert a link to another php code (banner.php) after the require_once line. What do I do?

 

<?php

$mysql_table = "cp_news";

        $com_table = "cp_comments";

require_once ("required.inc.php");

        getHeader();

if (!$_REQUEST) {

$s = 0;

$result = MYSQL_QUERY("SELECT * FROM $mysql_table ORDER BY topic_id DESC LIMIT $max_news") or die (mysql_error());

} else {

$s = $_REQUEST['s'];

$result = MYSQL_QUERY("SELECT * FROM $mysql_table ORDER BY topic_id DESC LIMIT $max_news, $s") or die (mysql_error());

}

$count = MYSQL_QUERY("SELECT * FROM $mysql_table") or die (mysql_error());

$rows = mysql_num_rows($count);

if ($rows == "0") {

echo "

        <h2>no news!</h2>

        <p>There are no news items</p>

       

        ";

} else {

while ($mysql=mysql_fetch_array($result)) {

                  $res = mysql_query("select count(*) from $com_table where topic_id = {$mysql[topic_id]}");

                  $count = 0;

                  if (list($c) = mysql_fetch_array($res)) $count = $c;

 

echo "<h2>" . checkContent($mysql[news_topic]) . "<font class=\"date\">" . $mysql[topic_date] . "</font><br /></h2>

            <p><span class=\"poster\">Posted by: " . checkContent($mysql[news_author]) . "</span><br />

            " . checkContent($mysql[news_message]) . "

            </p><br />

            ";

 

 

        $pref = ($count != 1 ? 's' : '');

 

        if ($mysql[comments_enabled] == 1) { # comments enabled

            echo "<p class=\"comments\">$count Comment{$pref} - <a href=\"viewnews.php?id={$mysql[topic_id]}\">View/Add Comments</a></p>";

        }

        elseif ($mysql[comments_enabled] == 0 && $count > 0) { # comments locked

            echo "<p class=\"comments\">$count Comment{$pref} - <a href=\"viewnews.php?id={$mysql[topic_id]}\">View Comments</a></p><div id=\"contentFt\"></div>";

        }

        else { } # comments disabled

 

 

 

}

}

getFooter();

?>

 

This is the banner.php code.

 

<?php

 

$folder = 'img/banners/';  //folder where images are held

 

    $extList = array();        //You can add more image types

$extList['gif'] = 'image/gif';

$extList['jpg'] = 'image/jpeg';

$extList['jpeg'] = 'image/jpeg';

$extList['png'] = 'image/png';

 

 

$img = null;

 

if (substr($folder,-1) != '/') {

$folder = $folder.'/';

}

 

if (isset($_GET['img'])) {

$imageInfo = pathinfo($_GET['img']);

if (

    isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&

        file_exists( $folder.$imageInfo['basename'] )

    ) {

$img = $folder.$imageInfo['basename'];

}

} else {

$fileList = array();

$handle = opendir($folder);

while ( false !== ( $file = readdir($handle) ) ) {

$file_info = pathinfo($file);

if (

    isset( $extList[ strtolower( $file_info['extension'] ) ] )

) {

$fileList[] = $file;

}

}

closedir($handle);

 

if (count($fileList) > 0) {

$imageNumber = time() % count($fileList);

$img = $folder.$fileList[$imageNumber];

}

}

 

if ($img!=null) {

$imageInfo = pathinfo($img);

$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];

header ($contentType);

readfile($img);

} else {

if ( function_exists('imagecreate') ) {

header ("Content-type: image/png");

$im = @imagecreate (100, 100)

    or die ("Cannot initialize new GD image stream");

$background_color = imagecolorallocate ($im, 255, 255, 255);

$text_color = imagecolorallocate ($im, 0,0,0);

imagestring ($im, 2, 5, 5,  "IMAGE ERROR", $text_color);

imagepng ($im);

imagedestroy($im);

}

}

 

?>

 

Thank you for your help!

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.