Nov 22, 2009

Need Help Is Adding A PHP Based News Module To My Site

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Need Help Is Adding A PHP Based News Module To My Site

marretas
Hey guys i need a simple help

i'm builing a homesite and i have a little spot for news. Well i just place there the Topics and add a link to another page "news.php". Well its obvious that i dont want to build a file for each news that i have so i know that exists a way to work with SQL & PHP. I will show want i'm doing

CODE
<?php
       require ('mysql.php');

       $query="SELECT * FROM News ORDER BY `data` ASC LIMIT 0,5 ";
       $result=mysql_query($query);
           $num=mysql_num_rows($result);

mysql_close();

echo "<font color='336699'><b>Outras Other News</b></font><br>";

$i=0;
while ($i < $num) {

$codigo=mysql_result($result,$i,"codigo");
$foto=mysql_result($result,$i,"foto");
$titulo=mysql_result($result,$i,"titulo");
$subtitulo=mysql_result($result,$i,"subtitulo");
$texto=mysql_result($result,$i,"texto");
$data=mysql_result($result,$i,"data");

echo " <br>";
echo "<li> <a href='news.php?Codigo=$codigo'>$titulo</a></li>";

$i++;
}

?>


Well this first code get from DB the news and then i've built the link code :

CODE
echo "<li> <a href='news.php?Codigo=$codigo'>$titulo</a></li>";


Now i've build the news.php. My Questions is this : I can't get data.
There the news.php code

CODE
<?php
      include ('mysql.php');
      $select= "SELECT FROM news Where Codigo='$codigo' ORDER BY `data` ASC";
      $selectdo=mysql_query($select);
      $num=mysql_num_rows($result);
      mysql_close();
      $i=0;
      while ($i < $num) {
      $codigo=mysql_result($result,$i,"codigo");
      $titulo=mysql_result($result,$i,"titulo");
      $i++;
}
    ?>


Whats its rong ? give me an help biggrin.gif

 

 

 


Comment/Reply (w/o sign-up)

marretas
I've resolved my problem

i just needed to add : $_GET['codigo']; before

CODE
... $query="SELECT * FROM News ORDER BY `data` ASC LIMIT 0,5 ";
       $result=mysql_query($query);
           $num=mysql_num_rows($result); ...


Comment/Reply (w/o sign-up)

twitch
***TOPIC RESOLVED. CLOSED.***

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : adding, php, based, news, module, site

  1. Automated Product Suggestion Script
    Compare user lists and suggest related items based on pattern matching (2)
  2. Extplorer
    A PHP -and JavaScript- based File Manager (7)
    Browsing the ExtJS examples website i found this excellent web-based file manager called
    eXtplorer . eXtplorer allows you to browse your webserver folders with an intuitive Layout which
    makes working with files very easy, and thanks to the great ExtJS Javascript Library you can drag
    & drop folders and files, filter directories and sort the file list using various criteria. You can
    use eXtplorer to for example: browse directories & files on the server. edit, copy, move, delete
    files. search, upload and download files. create and extract archives. create new fil....
  3. Adding Security Enhancements To Php Programs
    Security enhancements of PHP programs (0)
    PHP is becoming the language for even general programming more as it has seen from PHP4 to PHP5. PHP
    originally started as CGI script language connected with the internet. Thus, PHP is closely related
    with the internet and security - whether the problem comes from security leak point of internet
    protocols or not - problems related to the internet. There are two major security issues when your
    PHP program(s) has something to do with the internet. There can be memory leak and security leak
    from the program of PHP not connected - or connected - to the internet by PHP settin....
  4. Php - Browser Based Editor
    (3)
    I'm trying to set up some tools for a number of developers to use in the creation of a
    text-based MMORPG. I'd like to be able to show directory structure and allow them to easily see
    which files are where - then to be able to edit the pages from their browser. It would also be a
    neat feature that they could upload some files from their computer. Last time I needed this I built
    it myself, but it was restricted to 2 directories only and I ended up storing the file structure in
    text files. Anyways I'm debating rebuilding the entire thing but I can't help ....
  5. Rss/atom Feed For Php
    news feed (5)
    Hi I want to put Link of latest posts and a short text of that post from other xml (rss/atom,...)
    feeds to my page. XML addresses are stored in a mysql database. Please offer me a free and no ads
    RSS/XML Reader script. Thanks....
  6. Should This Great Site Offer Imagemagick ?
    May be the admin of this site think over it. (3)
    Hi As we all know that this website is very good and offering good services. I just wanna know if
    other people also want ImageMagick to be installed on this server with free accounts... so please
    let me know and lets check if the Admin of this site can isntall it..... Fun....
  7. Php :: Adding Image Over Image
    (5)
    Hi Masters & Champions. I want some help regarding putting and image over some location (x pixel ,
    y pixel) of an image. Here it is quite important to note that the mage which is Inserted over an
    image must be clickable. Like for example suppose i put T on an image DD then the T must be
    clickable. Please gudie as this is quite important for me . Thanks ....
  8. Php Question Re Adding A Link
    inside a top frame (2)
    I have a directory site that someone else programmed for me a couple of years ago. I have been
    making my own modifications to the script, and generally not running into many issues, since the
    changes are usually pretty basic. When a visitor clicks on a category, it takes them to a category
    page which lists all the sub categories, and under each category is a list of the links in it. When
    you click on one of the links, it takes you to a frame page. I have a tiny frame across the top
    which allows them to stay within the site. (Q) I would like to add a tiny link in my ....
  9. Simple PHP News System Problems
    (1)
    For the new version of my website I'm trying to make a very simple newssytem based on php. Each
    newsitem will get it's own html page, something like this: CODE Welkom HERE
    COMES THE TXT All other data will be stored in a file called news.inc CODE $news
    = array(); $news = '110706_jovolka.html'; $news = '110706_lorum.html'; $news =
    '090706_welkom.html'; $title = array(); $title = 'Over JoVolKa'; $title =
    'Lorum Ipsum'; $title = 'Welkom'; $date = array(); $date = '11/....
  10. Friend Networking Script... Help!
    Adding & removing friends (1)
    I'm creating my own friend network script which is going to be a combo of MySpace/Facebook and
    an AIM profile. One of the most important features is the adding of friends. The way to do this is
    probably simple & I'll kick myself when I see the code to do it. What needs to happen is a
    friend clicks a link which sends an internal message through the scripts messaging system (like a PM
    on a forum) to the other person to approve or deny the request. In that message, there needs to be a
    link to a page which executes a PHP script which updates the database adding b....
  11. PHP Script: Separating News Into Pages
    (2)
    look. I' ve got such a script to add news: CODE if($mess&&$subj) {
            $fp=fopen("news.txt", "a");         $d=date("d").".".date("m").".".date("Y");         $c=0;
            if(file_exists("news.txt")&&filesize("news.txt")>0) {             if($c==0) {
                    $news=" |$subj|$d|$login|$mess\n";             }             else {
                    $news=" |$subj|$d|$login|$mess";             }         }         else {
                if($c==0) {                 $news="|$subj|$d|$login|$mess\n";             }
                else {                 $news="|$subj|$d|$lo....
  12. Dynamic Site Design - Where Do I Start ?
    (7)
    I am new to php. I have some programing background in html, javascript, and c++ but have never done
    anything in php Can someone reccomend some good sites or books etc that can help someone who is
    completely new? My ultimate goal is to make a game like/similar to ponyisland.net....
  13. How Can I Make A PHP-based Web Gallery
    (4)
    how can i make a gallery in php like this one; but it has to show the images in the maps under it
    too; CODE    # Do we have a path? if not, it's the current directory    $path = $_GET ;
       if( !isset( $path ) || $path == "" )  {      $path = ".";    }    # Initialise list arrays,
    directories and files separately and array counters for them    $d_arr = array(); $d = 0;    $f_arr
    = array(); $f = 0;    # Open possibly available directory    if( is_dir( $path ) ) {      if(
    $handle = opendir( $path ) ) {          while( false !== ( $file = readdir( $handle ) )....
  14. Multilingual Site: Send The User To Page Of Choice
    (6)
    If you have one site in diferent laanguages, this simple script can redirect the user to the correct
    page acording to his/her language: CODE // Enslish EUA elseif ($HTTP_ACCEPT_LANGUAGE ==
    "en-us"){ header("Location: index_eng.html"); } // Inglęs UK elseif ($HTTP_ACCEPT_LANGUAGE ==
    "en-gb"){ header("Location: ingles_enuk.html"); } // Portuguese if ($HTTP_ACCEPT_LANGUAGE ==
    "pt-br"){ header("Location: index_ptbr.html"); } //German elseif ($HTTP_ACCEPT_LANGUAGE ==
    "de-de"){ header("Location: index_ger.html"); } // Swedish elseif ($HTTP_ACCEPT....
  15. How Do I Make PHP Based Image Gallery Like This?
    Help Needed (20)
    is it possible to make a page in php, with a url like this:
    httq://www.mysite.com/viewer.php?http://www.mysite.com/galleries/01 (This is a sample link, read
    below) so that in what i change the last part the gallery will change with it? so that i just have
    to make one php-page and this page just shows all the imaes in the map thats in the url after the
    questionmark?? thanks,....
  16. Using Bitflags To Restrict Site/page Permissions
    (1)
    My professor is designing a website that uses bit-flag checking to allow access to certain pages.
    You login, validate login, and store their allowed bit flag into a session variable. Then you
    compare to see if they have access or not. It's fairly new to me, but it's apparently very
    common with linux users. Sounds interesting to me, just wondering if any one has used this, or is
    it a little too much for simple pages. His site however is going to be more of "software" for
    several users. Is it very secure and does it work well?....
  17. How To Use Cookie In Your Web Site ?
    this semple code to use and get cookie (1)
    what is the cookie ? the cookis it is some info sent and save in user computer whare i can use the
    cookies? becouse the cookies it like the header you can not send it after any output wes sent so
    you must send the cookies before any output like as ,echo and any other code i well make an E.X.
    to use the cookies you must have 2 file index.php update.php ---------- in the index.php add this
    code CODE    // This section must go at the top of the page that will display    // the
    users favorites.  These are the 'default' URLs that the user    // will se....
  18. Do You Want A Mail Form In Your Site
    (2)
    Notice from m^e: Repeat post. Credits reduced by 5 days. Learn to USE
    THE SEARCH BUTTON before you make such posts. did you want to have in your web site mail form
    that allow the user to send mails to anther mail from his mail e.g. the compose in yahoo CODE
    from to cc bcc subject
    function param($Name)         {         global
    $HTTP_POST_VARS;         if(isset($HTTP_POST_VARS ))            return($H....
  19. Help: Trying To Create Web-based Compiler W/ Php
    (9)
    Hi guys,     Need some serious scripting help. I'm trying to come up with a web-based compiler.
    here's how it's going to work. 1. The user is given a form with a large textarea to enter
    code (lets assume C++). 2. Upon submit the script takes the entire text from the textarea and writes
    it to a file. 3. Then it calls GCC the linux C compiler and passes this file as an arguement to it,
    as well as another arguement which is the name of the output file. 4. It then chmods the output file
    to make it executable. 5. Then it runs the output binary and pipes the conso....
  20. Own Links On Site
    (6)
    I'm thinking of having some kind of system so the users can register and then put up their
    links. Everything should be saved in some kind of database. Anyone now any tutorial or guide or
    something like that of how to do that?....
  21. PHP Based Site Access Authentication - Help
    How to block parts of your web-site ?? (4)
    How can i program my web page using php that when the value of the login box is equal to some string
    then go to my success.html otherwise on my fail.html????help me guys!
    ------------------------------------ It would help the readers far better to understand what your
    problem is - if you state the nature of it in short in your topic title, instead of just "Php help".
    It'll also get you a lot more responses. Am changing your topic title to give you an example.
    All the best /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> m^e....
  22. Site Counters - Help Needed
    (13)
    I want a good Site counter(to keep track of visitors) for my site..... can nebody temme.....
    where will i get free stuff on this... (dont ask me to google..and try out..i am doing that..just in
    case u know someplace) OR Can how do i design my own (which seems quite....difficult for me) Plz
    help!! Satya....
  23. Php Script To Download File From Another Site
    (11)
    hi i need a php or java script code for downloading files from other sites to my site for example:
    http://download.com/file.zip to http://mysite.com/file.zip thanks....
  24. How Do U Make Members Only Web-site
    (7)
    how do u make it that only a member of that site can view that page?....

    1. Looking for adding, php, based, news, module, site

See Also,

*SIMILAR VIDEOS*
Searching Video's for adding, php, based, news, module, site
advertisement



Need Help Is Adding A PHP Based News Module To My Site

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com