1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Using A Portion Of ".PHP" Script (Attached)

Discussion in 'Web Design & Development' started by TW.87, Jan 28, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. TW.87

    TW.87 Thread Starter

    Joined:
    Dec 29, 2005
    Messages:
    308
    I have this script for a news article system that I am using for a website I am currently working on. However, this script provides access areas for three different pages ("News(News).php?Navigation=News", "News(News).php?Navigation=ArchivedNews", "News(News).php?Navigation=Article").

    What I would like to do is to use the first portion of code ("News(News).php?Navigation=News"), and remove it from this page and place it on another page. The page I want to place it on already is named and the below script is only one of several elements on that page, so it cannot dominate the file-name for that page, etcetera.

    Basically, what changes do I need to make to remove the "News(News).php?Navigation=News" portion of the below script to place it in another already coded page to have it display there?

    Code:
    <?php
    
    include("News(Configuration).php");
    
    $NewsLocation = $_GET['Navigation'];
    
    if($NewsLocation == "News")
    
    {
    
    $NewsConnect = mysql_connect($NewsServer, $NewsServerUsername, $NewsServerPassword) or die(mysql_error());
    
    $NewsQuery = "SELECT * FROM News ORDER BY NewsID DESC LIMIT 5";
    
    $NewsResult = mysql_db_query($NewsServerDatabase, $NewsQuery, $NewsConnect) or die(mysql_error());
    
    while ($NewsField = mysql_fetch_array($NewsResult))
    
    {
    
    print("<table border=\"0PX\" cellpadding=\"0PX\" cellspacing=\"0PX\">");
    
    print("<tr>");
    
    print("<td width=\"84PX\">");
    
    print("$NewsField[1]</td>");
    
    print("<td width=\"390PX\"> ");
    
    print substr("<a href=\"?Navigation=Article&amp;NewsID=$NewsField[0]\">$NewsField[2]</a>",0,60);
    
    print("</td>");
    
    print("</tr>");
    
    print("</table>");
    
    }
    
    }
    
    if($NewsLocation == "ArchivedNews")
    
    {
    
    $NewsConnect = mysql_connect($NewsServer, $NewsServerUsername, $NewsServerPassword) or die("MySQL Error: 2");
    
    $NewsQuery = "SELECT * FROM News ORDER BY NewsID DESC";
    
    $NewsResult = mysql_db_query($NewsServerDatabase, $NewsQuery, $NewsConnect) or die("MySQL Error: 3");
    
    while ($NewsField = mysql_fetch_array($NewsResult))
    
    {
    
    print("<table border=\"0PX\" cellpadding=\"0PX\" cellspacing=\"0PX\">");
    
    print("<tr>");
    
    print("<td width=\"84PX\">");
    
    print("$NewsField[1]</td>");
    
    print("<td width=\"390PX\"> ");
    
    print substr("<a href=\"?Navigation=Article&amp;NewsID=$NewsField[0]\">$NewsField[2]</a>",0,60);
    
    print("</td>");
    
    print("</tr>");
    
    print("</table>");
    
    }
    
    }
    
    if($NewsLocation == "Article")
    
    {
    
    $NewsID = $_GET['NewsID'];
    
    $NewsConnect = mysql_connect($NewsServer, $NewsServerUsername, $NewsServerPassword) or die("MySQL Error: 4");
    
    $NewsQuery = "SELECT * FROM News WHERE NewsID=$NewsID";
    
    $NewsResult = mysql_db_query($NewsServerDatabase, $NewsQuery, $NewsConnect) or die("MySQL Error: 5");
    
    if ($NewsField = mysql_fetch_array($NewsResult))
    
    {
    
    print("<table border=\"0PX\" cellpadding=\"0PX\" cellspacing=\"0PX\">");
    
    print("<tr>");
    
    print("<td>");
    
    print("$NewsField[1]");
    
    print("</td>");
    
    print("</tr>");
    
    print("<tr>");
    
    print("<td>");
    
    print("<br>");
    
    print("</td>");
    
    print("</tr>");
    
    print("<tr>");
    
    print("<td>");
    
    print("$NewsField[2]");
    
    print("</td>");
    
    print("</tr>");
    
    print("<tr>");
    
    print("<td>");
    
    print("<br>");
    
    print("</td>");
    
    print("</tr>");
    
    print("<tr>");
    
    print("<td>");
    
    print("$NewsField[3]");
    
    print("</td>");
    
    print("</tr>");
    
    print("<tr>");
    
    print("<td>");
    
    print("<br>");
    
    print("</td>");
    
    print("</tr>");
    
    print("<tr>");
    
    print("<td>");
    
    if($NewsField[4] == "Yes")
    
    {
    
    print("This article has corresponding images that can be viewed by clicking here.");
    
    print("<tr>");
    
    print("<td>");
    
    print("<br>");
    
    print("</td>");
    
    print("</tr>");
    
    }
    
    print("</td>");
    
    print("</tr>");
    
    print("<tr>");
    
    print("<td>");
    
    print("<a href=\"#\">Return</a> <a href=\"#\">Print Article</a>");
    
    print("</td>");
    
    print("</tr>");
    
    print("</table>");
    
    }		
    
    }
    
    ?>
     
  2. Sequal7

    Sequal7

    Joined:
    Apr 14, 2001
    Messages:
    2,382
    What script for news article system are you using? You have tried SSI $NewsLocation = news as the include?

    Does the readme say how to include specific articles, most have this ability dependant on your preferences.

    an example Include is:
    <?php $NewsLocation="News"; include "News(News).php"; ?>
     
  3. TW.87

    TW.87 Thread Starter

    Joined:
    Dec 29, 2005
    Messages:
    308
    That script that I posted is the "News(News).php" file, and because it was built for me, it didn't come with any documentation.

    As it stands, that script, along with the necessary database, works perfectly. But, I just want to take the first portion of that script and place it in another page that has already been built.
     
  4. TW.87

    TW.87 Thread Starter

    Joined:
    Dec 29, 2005
    Messages:
    308
    I've got it worked out. I just need to copy and paste the necessary code (as above), and then copy and paste in the variables (server, database, username and password) for connecting to the database, and it works.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/437888

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice