Welcome Guest ( Log In | Register )



 
Closed TopicStart new topic
> Need Help Is Adding A PHP Based News Module To My Site
marretas
post Feb 20 2006, 12:15 PM
Post #1


Member - Active Contributor
Group Icon

Group: Members
Posts: 98
Joined: 27-January 06
Member No.: 10,907



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


This post has been edited by miCRoSCoPiC^eaRthLinG: Feb 20 2006, 01:41 PM
Go to the top of the page
 
+Quote Post
marretas
post Feb 20 2006, 05:57 PM
Post #2


Member - Active Contributor
Group Icon

Group: Members
Posts: 98
Joined: 27-January 06
Member No.: 10,907



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); ...

Go to the top of the page
 
+Quote Post
twitch
post Feb 21 2006, 07:29 AM
Post #3


Veteran Nut
Group Icon

Group: Members
Posts: 527
Joined: 4-October 05
From: UK
Member No.: 8,895



***TOPIC RESOLVED. CLOSED.***
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How Do U Make Members Only Web-site(7)
  2. Php Script To Download File From Another Site(9)
  3. PHP Based Site Access Authentication - Help(4)
  4. Help: Trying To Create Web-based Compiler W/ Php(9)
  5. Do You Want A Mail Form In Your Site(2)
  6. How To Use Cookie In Your Web Site ?(1)
  7. Using Bitflags To Restrict Site/page Permissions(1)
  8. How Do I Make PHP Based Image Gallery Like This?(20)
  9. Multilingual Site: Send The User To Page Of Choice(6)
  10. How Can I Make A PHP-based Web Gallery(4)
  11. Dynamic Site Design - Where Do I Start ?(7)
  12. PHP Script: Separating News Into Pages(2)
  13. Friend Networking Script... Help!(1)
  14. Simple PHP News System Problems(1)
  15. Php Question Re Adding A Link(2)
  1. Php :: Adding Image Over Image(5)
  2. Should This Great Site Offer Imagemagick ?(3)
  3. Rss/atom Feed For Php(5)
  4. Php - Browser Based Editor(3)
  5. Adding Security Enhancements To Php Programs(0)
  6. Extplorer(7)
  7. Automated Product Suggestion Script(2)


 



- Lo-Fi Version Time is now: 5th December 2008 - 01:33 AM