Jump to content
xisto Community
Sign in to follow this  
marretas

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

Recommended Posts

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

<?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 :

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

<?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 B)
Edited by miCRoSCoPiC^eaRthLinG (see edit history)

Share this post


Link to post
Share on other sites

I've resolved my problem

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

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

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.