sid | pnItitle
--------------
1 | news1
--------------
2 | news2
Problem w tym, że każdy link prowadzi do tego samego artykułu. Jak zrobić aby np. gdy wpiszemy w szukarce news, to zostanie nam pokazane (wyniki wyszukiwania):
news1
news2
I gdy klinie się na news1 to przeniesie nas do strony modules.php?op=modload&name=newsy&file=newsy&id=sid danego newsa, czyli w tym wypadku 1.POMOCY
Kod
<?php
$ModName = basename(dirname(__FILE__));
modules_get_language();
$ModName = $GLOBALS['ModName'];
include ("header.php");
$host=pnConfigGetVar('dbhost');
$usern=pnConfigGetVar('dbuname');
$passw=pnConfigGetVar('dbpass');
$datab=pnConfigGetVar('dbname');
$prefix=pnConfigGetVar('prefix');
$lang=pnSessionGetVar('lang');
$polaczenie = mysql_connect($host, $usern, $passw);
echo "<form ACTION=modules.php?op=modload&name=newsy&file=szukaj method=post>
<input type=text name=words value=$words>
<input type=hidden name=good value=yes>
<input type=submit value=Search>
</form><BR>";
//szukaj
if($_POST['good']=='yes')
{
echo("<font face=\"tahoma\" size=\"3\"><b>Wyniki szukania dla $words</b></font><br><br>");
$location = "$host";
$username = "$usern";
$password = "$passw";
$database = "$datab";
$db_table = "nuke_stories";
$mysql_row = "pn_title";
$conn = mysql_connect("$location","$username","$password");
if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
$query = "ALTER TABLE $db_table ORDER BY id DESC";
$result = mysql_query($query); // bad coding yes;)
$query = "SELECT * FROM $db_table WHERE pn_topic='12'";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
if(preg_match("/$words/i", $row[$mysql_row]))
{
$rawid = ($row[event_id]);
$rawmonth = ($row[event_date]);
$rawdate = ($row[event_venue]);
$rawyear = ($row[event_headline]);
$newnews = preg_replace("/$words/i", "<b><font color=\"orange\">$words</font></b>", $row[$mysql_row]);
$zapytanie = "SELECT `pn_sid` FROM nuke_stories WHERE `pn_topic`='12'";
$wykonaj = mysql_query($zapytanie);
while(($tablica=mysql_fetch_array($wykonaj,MYSQL_ASSOC))!=null){
$display = '<font face="tahoma" size="2"><b>' .$rawmonth . ' ' . $rawdate . '<A HREF=modules.php?op=modload&name=newsy&file=newsy&id='.$tablica['pn_sid'].'> ' . $rawyear . '</b><br>' . $newnews . '</A></font><br><br>'; }
echo($display);
$foundcount++;
}
$totalcount++;
}
if(is_null($foundcount)){$foundcount=0;}
echo("<font face=\"tahoma\" size=\"3\"><b>Znaleziono $foundcount wynik(ów) z $totalcount</b></font>");
}
//koniec
?>
$ModName = basename(dirname(__FILE__));
modules_get_language();
$ModName = $GLOBALS['ModName'];
include ("header.php");
$host=pnConfigGetVar('dbhost');
$usern=pnConfigGetVar('dbuname');
$passw=pnConfigGetVar('dbpass');
$datab=pnConfigGetVar('dbname');
$prefix=pnConfigGetVar('prefix');
$lang=pnSessionGetVar('lang');
$polaczenie = mysql_connect($host, $usern, $passw);
echo "<form ACTION=modules.php?op=modload&name=newsy&file=szukaj method=post>
<input type=text name=words value=$words>
<input type=hidden name=good value=yes>
<input type=submit value=Search>
</form><BR>";
//szukaj
if($_POST['good']=='yes')
{
echo("<font face=\"tahoma\" size=\"3\"><b>Wyniki szukania dla $words</b></font><br><br>");
$location = "$host";
$username = "$usern";
$password = "$passw";
$database = "$datab";
$db_table = "nuke_stories";
$mysql_row = "pn_title";
$conn = mysql_connect("$location","$username","$password");
if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
$query = "ALTER TABLE $db_table ORDER BY id DESC";
$result = mysql_query($query); // bad coding yes;)
$query = "SELECT * FROM $db_table WHERE pn_topic='12'";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
if(preg_match("/$words/i", $row[$mysql_row]))
{
$rawid = ($row[event_id]);
$rawmonth = ($row[event_date]);
$rawdate = ($row[event_venue]);
$rawyear = ($row[event_headline]);
$newnews = preg_replace("/$words/i", "<b><font color=\"orange\">$words</font></b>", $row[$mysql_row]);
$zapytanie = "SELECT `pn_sid` FROM nuke_stories WHERE `pn_topic`='12'";
$wykonaj = mysql_query($zapytanie);
while(($tablica=mysql_fetch_array($wykonaj,MYSQL_ASSOC))!=null){
$display = '<font face="tahoma" size="2"><b>' .$rawmonth . ' ' . $rawdate . '<A HREF=modules.php?op=modload&name=newsy&file=newsy&id='.$tablica['pn_sid'].'> ' . $rawyear . '</b><br>' . $newnews . '</A></font><br><br>'; }
echo($display);
$foundcount++;
}
$totalcount++;
}
if(is_null($foundcount)){$foundcount=0;}
echo("<font face=\"tahoma\" size=\"3\"><b>Znaleziono $foundcount wynik(ów) z $totalcount</b></font>");
}
//koniec
?>