Current location: Hot Scripts Forums » Programming Languages » PHP » php help


php help

Reply
  #1 (permalink)  
Old 05-04-04, 03:30 PM
jasperma jasperma is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
php help

ok, so i have this newsscript. It's located here: http://www.jumpstartpunk.com/index2.php

When you click on 'full article' or 'comments' it goes to a page where you can see the comments or article there.
Instead of it going to the 'article' or 'comments' in that page, i would like it to popup. I tried messing around with it, but it didn't really work.

here is the code of the newsscript.

PHP Code:

<?PHP


echo "<link href=\"www.jumpstartpunk.com/css/styles.css\" rel=stylesheet type=\"text/css\">";



// ************************************************************
//        File Includes
// ************************************************************

    
include("includes/dbconnect.php");
    include(
"includes/settings.php");
    include(
"includes/functions.php");

// ************************************************************
//        The following code initiates the archive page numbers at
//        the bottom of the news page - Part 1.
//    
//        $postlimit is the number of news articles to display per
//        page.
// ************************************************************

    
$query "SELECT news_id FROM news_articles";
    
$result mysql_query($query)
        or die (
mysql_error());
        
    
$newsrows mysql_num_rows($result);

    if (empty(
$offset)) {

        
$offset "0";
    
    }
    
// ************************************************************
//        Get news articles from SQL.
//
//        If comments are to be displayed ($action == comments), 
//        the query will be different; only one article will be 
//        selected.
// ************************************************************

    
if ($action == "comments" || $action == "article" || $action == "email") {
    
        
$news_id $_GET['news_id'];
    
        
$query "SELECT * FROM news_articles WHERE news_id = '$news_id' LIMIT 1";
        
$result mysql_query($query)
            or die (
mysql_error());
            
    } else {

        
// Get all non-sticky news articles
                
        
$query "SELECT * FROM news_articles WHERE sticky = '' OR sticky = 'off' ORDER BY news_id DESC LIMIT $offset,$postlimit";
        
$result mysql_query($query)
            or die (
mysql_error());
        
// ************************************************************
//        Display the sticky post (if there is one) and 
//        if comments are not being viewed.
// ************************************************************    

        
$query "SELECT * FROM news_articles WHERE sticky = 'on'";
        
$sticky mysql_query($query)
            or die (
mysql_error());
            
        
$rows mysql_num_rows($sticky);
        
        while (
$data mysql_fetch_assoc($sticky)) {
        
            
$news_id    $data['news_id'];
            
$title    $data['title'];
            
$poster    $data['poster'];
            
$date        $data['date'];
            
$text        $data['snippet'];
            
$snippet    emoticons($text);
            
$snippet    nl2br($snippet);
            
$snippet stripslashes($snippet);
                        
                                                
            echo 
"
            <table align='center' border='0' width='
$tablewidth' cellpadding='0' cellspacing='1' bgcolor='$rgb_border'>
            <tr>
                <td bgcolor='
$rgb_title' colspan='2' align='center'><font size='$fontsize' face='$fontface' color='$fontcolor'><b><font size='$fontsize'>$title</font></b></font></td>
            </tr>
            <tr>
                <td bgcolor='
$rgb_article' colspan='2'>
                
                <table border='0' width='100%' cellspacing='2' cellpadding='2'>
                <tr>
                    <td valign='top'><font size='
$fontsize' face='$fontface' color='$fontcolor'>$snippet</font></td>
                </tr>
                </table>
        
                </td>    
            </tr>
            </table>
            <br>"
;
        
        } 
//End While Loop    
        
    
//End Else Action
    
// ************************************************************
//        Begin loop to display articles until $postlimit is 
//        reached.
// ************************************************************

    
while ($data mysql_fetch_assoc($result)) {
    
        
$news_id    $data['news_id'];
        
$title    $data['title']; 
        
$poster    $data['poster'];
        
$date        $data['date'];
    
// ************************************************************
//        Count the number of comments associated with each 
//        article.
// ************************************************************

        
$query "SELECT com_id FROM news_comments WHERE news_id = '$news_id'";
        
$comments mysql_query($query);
        
        
$comments mysql_num_rows($comments);
        
// ************************************************************
//     Set some variables for the HTML output
// ************************************************************

        
if ($action == "article") {
        
            
$text        $data['snippet'];
            
$text        emoticons($text);
            
$snippet    nl2br($text);
            
$snippet stripslashes($snippet);
            
            
$text        $data['article'];
            
$test        $data['article'];

            if (!empty(
$test)) {

                
$divider    "<div align='center'><br><img src='http://www.jumpstartpunk.com/news/simplenews/images/dots.gif'></div><br>";

            }

            
$text        emoticons($text);
            
$article    nl2br($text);
            
$article    stripslashes($article);
            
        } else if (
$action == "email" || $action == "comment") {
            
            
$text        $data['snippet'];
            
$snippet    emoticons($text);
            
$snippet    nl2br($snippet);
            
$snippet stripslashes($snippet);
            
        } else {
        
            
$text        $data['snippet'];
            
$full_article $data['article'];
            
$snippet    emoticons($text);
            
$snippet    nl2br($snippet);
            
$snippet stripslashes($snippet);

            if (!empty(
$full_article)) {
        
                
$full_link " <a href='$PHP_SELF?action=article&news_id=$news_id'>Full Article</a>";

            } else {

                
$full_link "";

            }
        
        }

// ************************************************************
//        Begin HTML output for each news article.
//
//        Edit this section if you want to customize the layout
//        of the news articles on your page.
//
//        Printer friendly page opens in new window.
// ************************************************************    
        
echo "
        <table align='center' border='0' width='
$tablewidth' cellpadding='0' cellspacing='1' bgcolor='$rgb_border'>
        <tr>
            <td bgcolor='
$rgb_title' colspan='2'><font size='$fontsize' face='$fontface' color='$fontcolor'> <b><font size='$fontsize'>$title</font></b> - <i>Posted by $poster on $date</i></font></td>
        </tr>
        <tr>
            <td bgcolor='
$rgb_article' colspan='2'>
            
            <table border='0' width='100%' cellspacing='2' cellpadding='2'>
            <tr>
                <td><font size='
$fontsize' face='$fontface' color='$fontcolor'>$snippet $divider $article</font></td>
            </tr>
            </table>
            
        </tr>
        <tr>
            <td width='10%' bgcolor='
$rgb_icons' align='center'>
                <a href='
$PHP_SELF?action=email&news_id=$news_id'><img src='http://www.jumpstartpunk.com/news/simplenews/images/email.gif' hspace='2' border='0' align='middle' alt='Email this article to a friend'></a>
                <a href='print.php?news_id=
$news_id' target='_blank'><img src='http://www.jumpstartpunk.com/news/simplenews/images/printer.gif' hspace='2' border='0' align='middle' alt='Printer friendly version of this article'></a>
            </td>
            <td bgcolor='
$rgb_comment'>
            
            <table width='100%' cellpadding='0' cellspacing='0' border='0'>
            <tr>
                <td><font size='
$fontsize' face='$fontface' color='$fontcolor'>$full_link</font></td>
                <td align='right'><font size='
$fontsize' face='$fontface' color='$fontcolor'>($comments) <a href='$PHP_SELF?action=comments&news_id=$news_id'>Comments</a> </font></td>
            </tr>
            </table>

            </td>
        </table>
        <br>
        "
;
            



        if (
$action == "email") {
        
            if (isset(
$submit)) {
            
                
$name            $_POST['name'];
                
$email        $_POST['email'];
                
$sendemail    $_POST['sendemail'];
                
$news_id        $_GET['news_id'];
                
                if (empty(
$name)) {
            
                    echo 
"<div align='center'><font size='$fontsize' face='$fontface' color='$fontcolor'>You must enter your name.<p><a href='$PHP_SELF?action=email&news_id=$news_id'>Go Back</a></font></div>";
            
                } else if (empty(
$email)) {
            
                    echo 
"<div align='center'><font size='$fontsize' face='$fontface' color='$fontcolor'>You must enter your email address.<p><a href='$PHP_SELF?action=email&news_id=$news_id'>Go Back</a></font></div>";
            
                } else if (empty(
$sendemail)) {
            
                    echo 
"<div align='center'><font size='$fontsize' face='$fontface' color='$fontcolor'>You must enter your friend's email address.<p><a href='$PHP_SELF?action=email&news_id=$news_id'>Go Back</a></font></div>";
            
                } else {
                
                    
$query "SELECT news_id,title,snippet FROM news_articles WHERE news_id = '$news_id'";
                    
$result mysql_query($query)
                        or die (
mysql_error());
                    
                    
$data mysql_fetch_assoc($result);
                    
                    
$news_id        $data['news_id'];
                    
$title        $data['title'];
                    
$snippet        $data['snippet'];
                    
$snippet        stripslashes($snippet);
                    
$link            'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; 
                    
$linkvars    "?action=article&news_id=$news_id";
                    
$url            "$link$linkvars";
                                
                    
$subject    $title;
                    
$message    "
                
From: 
$name ($email)

$name thought you'd be insterested in this article on our web site: 

$title

Click on this link if you'd like to read the article: 

$url

"
;

                    
mail($sendemail$subject$message"");
    
                    echo 
"<div align='center'><font size='1' face='$fontface'>Your message to $sendemail has been sent!</font></div>";
                
                }
                            
            } else {
        
                echo 
"
                <form action='
$PHP_SELF?action=email&news_id=$news_id' method='post'>
                <table align='center' border='0' width='
$tablewidth' cellpadding='0' cellspacing='1' bgcolor='$rgb_border'>
                <tr>
                    <td bgcolor='
$rgb_title' colspan='2'><font size='$fontsize' face='$fontface' color='$fontcolor'> <b>Send Article to a Friend</b></font></td>
                </tr>
                <tr>
                    <td bgcolor='
$rgb_article' colspan='2'>
                    
                    <table border='0' align='center' cellspacing='2' cellpadding='2'>
                    <tr>
                        <td width='40%'><b><font face='
$fontface' size='$fontsize' color='$fontcolor'>Your Name</font></b></td>
                        <td><input type='text' name='name' size='25'></td>
                    </tr>
                    <tr>
                        <td><b><font face='
$fontface' size='$fontsize' color='$fontcolor'>Your E-Mail</font></b></td>
                        <td><input type='text' name='email' size='25'></td>
                    </tr>
                    <tr>
                        <td><b><font face='
$fontface' size='$fontsize' color='$fontcolor'>Your Friend's E-Mail</font></b></td>
                        <td><input type='text' name='sendemail' size='25'></td>
                    </tr>
                    </table>
                
                    </td>
                </tr>
                <tr>
                    <td bgcolor='
$rgb_comment'>
                                  
                    <table width='100%' border='0' cellspacing='0' cellpadding='0'>
                    <tr> 
                        <td width='50%' align='center' height='30'><input type='submit' name='submit' value='Send Email'></td>
                      <td width='50%' align='center'><input type='reset' name='reset' value='Clear Form'></td>
                 </tr>
                 </table>
            
                    </td>
                </tr>
                </table>
                </form>"
;
                
            } 
//End Submit
            
        
//End action == email
        
    
//End While Loop

    
if ($action == "comments") {
    
// ************************************************************
//        Process comment submition
// ************************************************************

        
if (isset($submit)) {
        
            
$news_id        $_GET['news_id'];
            
$username    $_POST['username'];
            
$comment        $_POST['comment'];
            
$comment        addslashes($comment);
            
$count        strlen($comment);
            
$date            date("m.d.Y" ,time());
            
            if (empty(
$username)) {
            
                echo 
"<div align='center'><font size='$fontsize' face='$fontface' color='$fontcolor'>Username is a required field!<p><a href='$PHP_SELF?action=comments&news_id=$news_id'>Go Back</a></font></div>";
            
            } else if (empty(
$comment)) {
            
                echo 
"<div align='center'><font size='$fontsize' face='$fontface' color='$fontcolor'>Comment is a required field!<p><a href='$PHP_SELF?action=comments&news_id=$news_id'>Go Back</a></font></div>";
            
            } else if (
$count $com_size) {

                echo 
"<div align='center'><font size='$fontsize' face='$fontface' color='$fontcolor'>Your comment must be fewer then $com_size characters, it's $count.<p><a href='$PHP_SELF?action=comments&news_id=$news_id'>Go Back</a></font></div>";

            } else {
            
                
$query    "INSERT INTO news_comments (news_id, guest, email, date, comment, guest_ip)
                                VALUES ('
$news_id', '$username', '$email', '$date', '$comment', '$ip')";
                
$result    mysql_query($query)
                    or die (
mysql_error());
                            
                echo 
"<div align='center'><font size='$fontsize' face='$fontface' color='$fontcolor'>Thanks $username, your comment was added succesfully!<p><a href='$PHP_SELF?action=comments&news_id=$news_id'>View Your Comment</a></font></div>";
                    
            }
    
// ************************************************************
//        Display the article's comments if submit was not clicked
// ************************************************************

        
} else {    

            
$news_id $_GET['news_id'];
    
            
$query "SELECT * FROM news_comments WHERE news_id = '$news_id'";
            
$result mysql_query($query)
                or die (
mysql_error());
        
            while (
$data mysql_fetch_array($result)) {
        
                
$com_id    $data['com_id'];
                
$guest    $data['guest'];
                
$ip        $data['guest_ip'];
                
$date        $data['date'];
                
$text        $data['comment'];
                
$text        stripslashes($text);
                
$text        strip_html($text);
                
$text        emoticons($text);
                
$text        nl2br($text);
        
                if (
$wordfilter == "on") {

                    
$comment    word_filter($text);

                } else {

                    
$comment $text;
    
                }

                echo 

                <table align='center' border='0' width='
$tablewidth' cellpadding='0' cellspacing='1' bgcolor='$rgb_border'>
                <tr>
                    <td bgcolor='
$rgb_title''><font size='$fontsize' face='$fontface' color='$fontcolor'> <i>Comment by <b>$guest</b> on $date</i></font></td>
                </tr>
                <tr>
                    <td bgcolor='
$rgb_article' colspan='2'>
                
                    <table border='0' cellspacing='2' cellpadding='2'>
                    <tr>
                        <td><font size='
$fontsize' face='$fontface' color='$fontcolor'>$comment</font></td>
                    </tr>
                    </table>

                </tr>
                </table>
                <br>"
;
        
            } 
//End While Loop
    
// ************************************************************
//        Display the Add Comments form
// ************************************************************

        
echo "
        <form name='form' action='
$PHP_SELF?action=comments&news_id=$news_id' method='post'>
        <table align='center' border='0' width='
$tablewidth' cellpadding='0' cellspacing='1' bgcolor='$rgb_border'>
        <tr>
            <td bgcolor='
$rgb_title' colspan='2'>
            
            <table border='0' width='100%' cellpadding='0' cellspacing='0'>
            <tr>
                <td width='50%'><font size='
$fontsize' face='$fontface' color='$fontcolor'><b><font size='$fontsize'> Add Comments</font></b></font></td>
                <td width='50%' align='right'><font size='
$fontsize' face='$fontface' color='$fontcolor'>[ <a href=\"javascript:openpopup()\">Help</a> ] </font></td>
            </tr>
            </table>
            
            </td>
        </tr>
        <tr>
            <td bgcolor='
$rgb_article' colspan='2'>
            
            <table border='0' align='center' cellspacing='2' cellpadding='2'>
            <tr>
                <td width='25%'><font size='
$fontsize' face='$fontface' color='$fontcolor'><b>Username</b> <font color='#FF3333'>*</font></font></td>
                <td><input type='text' name='username' value='Anonymous' size='25'></td>
            </tr>
            <tr> 
             <td height='25'> </td>
                <td height='25'>
                   <a href='Javascript:insertsmilie(\"[:)]\")'><img src='http://www.jumpstartpunk.com/news/simplenews/images/emoticons/smile.gif' align='middle' border='0' title='Happy [:)]' /></a>
                    <a href='Javascript:insertsmilie(\"[:(]\")'><img src='http://www.jumpstartpunk.com/news/simplenews/images/emoticons/frown.gif' align='middle' border='0' title='Sad [:{]' /></a>
                   <a href='Javascript:insertsmilie(\"[;)]\")'><img src='images/emoticons/wink.gif' align='middle' border='0' title='Wink [;)]' /></a>
                    <a href='Javascript:insertsmilie(\"[:D]\")'><img src='http://www.jumpstartpunk.com/news/simplenews/images/emoticons/biggrin.gif' align='middle' border='0' title='Big Grin [:D]' /></a>
                   <a href='Javascript:insertsmilie(\"[:p]\")'><img src='http://www.jumpstartpunk.com/news/simplenews/images/emoticons/tongue.gif' align='middle' border='0' title='Tongue [:p]' /></a>
                    <a href='Javascript:insertsmilie(\"[8)]\")'><img src='http://www.jumpstartpunk.com/news/simplenews/images/emoticons/cool.gif' align='middle' border='0' title='Cool [8)]' /></a>
                   <a href='Javascript:insertsmilie(\"[:o]\")'><img src='http://www.jumpstartpunk.com/news/simplenews/images/emoticons/eek.gif' align='middle' border='0' title='Suprised [:o]' /></a>
                   <font size='1' face='
$fontface'><i>(Click to add)</i></font>
                </td>
            </tr>
            <tr> 
             <td><b><font size='
$fontsize' face='$fontface' color='$fontcolor'><br><br>Comment <font color='#FF3333'>*</font></font></b></td>
             <td><textarea name='comment' rows='10' cols='50'></text></td>
         </tr>
            <tr>
                <td></td>
                <td><font size='
$fontsize' face='$fontface' color='$fontcolor'> * <i>Your comment can be a maximum of $com_size characters.</i></font></td>
            </tr>
            </table>
            
        </tr>
        <tr>
            <td bgcolor='
$rgb_comment' align='center'>
                                  
            <table width='100%' border='0' cellspacing='0' cellpadding='0'>
            <tr> 
                <td width='50%' align='center' height='30'><input type='submit' name='submit' value='Submit Comment'></td>
              <td width='50%' align='center'><input type='reset' name='reset' value='Clear Form'></td>
         </tr>
         </table>
            
            </td>
        </tr>
        </table>
        </form>"
;
        
        } 
//End Else Submit

    


// ************************************************************
//        Display News Archive page numbers - Part 2.
//
//        Only display page numbers on main news page.
// ************************************************************
    
    
$pages intval($newsrows $postlimit);

    if (
$newsrows $postlimit) {
    
       
$pages++;

    }    
        
    echo 
"
    <table align='center' cellPadding='0' cellSpacing='0' border='0' width='
$tablewidth'>
    <tr>
        <td>
            <font size='
$fontsize' face='$fontface' color='$fontcolor'>";
        
    if (!isset(
$action)) {
    
        echo 
"
            <b>News Archive</b> : "
;
        
        for (
$i 1$i <= $pages$i++) {

            
$newoffset $postlimit * ($i 1);

            echo 
"[<a href='$PHP_SELF?offset=$newoffset'>$i</a>]  ";

        }

    }
    
    echo 
"
            </font>
        </td>
    </tr>
    </table>
    <br>"
;
?>
thanks for any help.
Reply With Quote
  #2 (permalink)  
Old 05-05-04, 04:38 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
change this line:
PHP Code:

$full_link " <a href='$PHP_SELF?action=article&news_id=$news_id'>Full Article</a>"
to :
PHP Code:

$full_link " <a href=\"#\" onClick=\"window.open('$PHP_SELF?action=article&news_id=$news_id', 'Full_story', 'width=500,height=500');\">Full Article</a>"
this shall open a window with the full story in it ..
use JavaScript for that or use the target attribute _blank ..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 05-05-04, 11:38 AM
jasperma jasperma is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks a lot!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
PHP Dudes - Hi All stuart New Members & Introductions 4 05-03-04 01:22 PM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM
Realtime PHP Code Obfuscation barrywien General Advertisements 1 11-16-03 06:50 PM
How to convert php generated pages to SE friendly HTML or PHP(SE friendly) -CLASS 101 crippled PHP 1 11-16-03 06:37 AM


All times are GMT -5. The time now is 10:31 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.