Znaci ovdje su dvije baze categories i news
CREATE TABLE IF NOT EXISTS `categories` (
`CATEGORY_ID` int(11) NOT NULL auto_increment,
`cat_name` varchar(30) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`CATEGORY_ID`),
KEY `rubrika` (`cat_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=0 ;
CREATE TABLE IF NOT EXISTS `news` (
`NEWS_ID` int(11) NOT NULL auto_increment,
`CATEGORY_ID` varchar(60) collate utf8_unicode_ci default NULL,
`news_title` varchar(255) collate utf8_unicode_ci default NULL,
`news_body` text collate utf8_unicode_ci,
`news_body2` text collate utf8_unicode_ci,
`news_time` int(11) default '0',
PRIMARY KEY (`NEWS_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=0 ;
Stranica za izbor kategorije
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<?php
include 'konektuj.php';
$cat_name = $_GET["cat_name"];
$query2 = 'SELECT * FROM categories;';
$result2 = mysql_query($query2) or die('Query failed: ' . mysql_error());
?>
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<form name="form1" id="form1">
<select name="cat_name" onchange="MM_jumpMenu('parent',this,0)">
<option value="?s=vijesti">--izaberi--</option>
<?php
while ($row2 = mysql_fetch_assoc($result2)):
echo '<option value="?s=vijesti&rubrika='.$row2['CATEGORY_ID'].'"';
if ($rubrika == $row2['CATEGORY_ID'] ) {echo'selected';}
echo'>'.$row2['cat_name'].'</option>';
endwhile;
?>
</select>
</form>
</td>
</tr>
</table>
<?php
include 'konektuj.php'; ?>
<?php
if (isset($_GET['rubrika'])) {
$query_cl=mysql_query ("SELECT * FROM news WHERE NEWS_ID = '".$_GET['rubrika']."' LIMIT 1");
$prikazi=mysql_fetch_array($query_cl);
}
?>
<h1><center><?php echo $prikazi['naslov']; ?></center></h1>
<p>
<?php
$vijesti = nl2br(stripslashes($prikazi['vijesti']));
echo $vijesti;
?><br><br>
<?php
$novosti = nl2br(stripslashes($prikazi['novosti']));
echo $novosti;
?>
</p>
<?php mysql_close(); ?>
<?php
$stranica = $_GET["s"];
switch ( $stranica ) {
case "" :
case "kat":
include("kategorije.php");
break;
case "vijesti":
include("vijesti.php");
break;
case "pocetna":
include("pocetna.php");
break;
default :
include("pocetna.php");
break;
}
?>
Gdje grijesim jer mi se news uopste ne prikazuje na sajt.com?s=vijesti&rubrika=1 a nemam ni jednu gresku, znaci stanica bude prazna nema nista na njoj
Mozel mi ko pomoc ?
Unaprijed zahvalan ?
|