First of all, my scripts are usally simple 1's. Allthou i post them not knowing of any bugs and to the rules of posting in this forum category. I'm woundering should i post them in Coding or general help forum.
Anyway, heres my masterpiece.
// news.php is included into the index.php page.
<?php
$nid = $_GET[nid]; // Gets the nid "News ID"
include 'includes/connection.php'; // Creates my mysql connection
if ($nid >= 1){
include "includes/show_article.php"; // Shows a individual News article
} else {
include "includes/show_news.php"; // shows all the news, descriptions only
}
?>
// show_article.php
<?php
$news_query = mysql_query("SELECT * FROM news WHERE nid = '$nid'")
or die(mysql_error());
$cats_query = mysql_query("SELECT * FROM categories")
or die(mysql_error()); // cid,category
$user_query = mysql_query("SELECT uid,username FROM users")
or die(mysql_error());
$nid_row = mysql_fetch_array($news_query);
$user_row = mysql_fetch_array($user_query);
$cats_row = mysql_fetch_array($cats_query);
?>
<div style="border-style:solid; border-width:thin;">
<table>
<tr>
<td>MEGAHERTZA /
<?php
echo $cats_row[$nid_row[cid]]." / ".$nid_row[title];
?></td>
<td>NEWS ID:<a href="index.php?pid=news&nid=<?php echo $nid_row[nid]; ?>"><?php echo $nid_row[nid]; ?></a></td>
</tr>
</table>
<table>
<tr><td><?php echo $nid_row[article]; ?></td></tr>
</table>
<table width="100%">
<tr>
<td width="50%" align="left"><?php echo "Added by: ".$user_row[$nid_row[uid]]; ?></td>
<td width="50%" align="right"><?php echo "Added: ".$nid_row[timestamp]; ?></td></tr>
</table>
</div>
<br />
<?php
The show_news.php is fairly similer to the show_article so any improvements can be easilly made to the other.
Thanks again guys for you valued input.