witam mam mały problem z odczytem z bazy poniżej zamieszczam jej strukturę oraz fragment kodu php
CREATE TABLE `newsy` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tytulpl` text collate utf8_polish_ci NOT NULL,
`tytulde` text collate utf8_polish_ci NOT NULL,
`tytulit` text collate utf8_polish_ci NOT NULL,
`tytulgb` text collate utf8_polish_ci NOT NULL,
`trescpl` text collate utf8_polish_ci NOT NULL,
`trescde` text collate utf8_polish_ci NOT NULL,
`trescit` text collate utf8_polish_ci NOT NULL,
`trescgb` text collate utf8_polish_ci NOT NULL,
`data` int(11) NOT NULL,
`active` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=5 ;
fragment kodu php
<?
if(isset($_GET['lang'])) $_SESSION['lang']=$_GET['lang']; if(!isset($_SESSION['lang'])) $_SESSION['lang']='pl'; .
.
.
<br/><h1>Najnowsze informacje:</h1><br>
<!--newsy -->
<?php
function shortcut($tresc,$ile)
{
if ($licz>=$ile)
{
$tnij = substr($tresc," ",$ile); $txt = $tnij.'...';
}
else
{
$txt = $tresc;
}
return $txt;
}
#
# tutaj deklarujemy ilosc znakow jaka ma nam wyswietlic skrypt
#select tytul".$lang.", tresc".$lang." from tabela;
$ile = 100;
$query = mysql_query("select tytul".$lang." as tytul, tresc".$lang." as tresc from newsy WHERE active='1' order by id desc LIMIT 4"); {
$temat = $go;
$active = $rekord[5];
$id = $rekord[0];
echo '<b>'.$temat.'</b><br/>'; echo shortcut
($tresc,$ile); echo "<br/><a href='pokaz_news.php?news=$id'> więcej >>></a>";
}
echo '<a href="#">starsze wiadomości</a>'; ?>
?>
Problem polega na zapytaniu do bazy danych, nie mogę wyświetlić takich danych jak tytuł i treść w zależności od $lang. Próbowałem w ten sposób ale nie wyświetla nic:
<?php
$temat = $rekord("tytul")
?>
prin query wyświetla coś takiego Resource id #2. Prosiłbym o szybkie rozwiązanie problemu.
Pozdrawiam
Wojtek
Ten post edytował wojtekwro 22.02.2008, 17:38:23