Sending af id til nyt vindue...
Jeg har brug for lidt hjælp til et nyhedsscript. Jeg har fået det installeret helt fint, og har til dette spørgsmål lige lavet en hurtig test side, så jeg kan forklare Jer hvad jeg mener.http://www.linkinparkclub.com/fch/nyheder/what.php
Når man trykker på linket \"Read more\" for hver enkelt nyhed, så vil jeg gerne have at der åbner et lille vindue, evt. ved hjælp af javascript
java script:PopWin(\'Her bliver id som tilhører den valgte nyhed overført og så bliver den pågældende og kun denne nyhed vist i det lille vindue)
Håber at i forstår hvad jeg mener, til formålet smider jeg lige koden ind, som hører til show_news.php som i vil få brug for at rette i.
<?php
if ($back==1)
{
if ($cookie_advancesearch)
{
$advancesearch=$cookie_advancesearch;
$search=$cookie_search;
$short=$cookie_short;
$news=$cookie_news;
$title=$cookie_title;
$archive=$cookie_archive;
$catagory_id=$cookie_catagory_id;
}
else
{
$search=$cookie_search;
}
}
if ($advancesearch && !$searching)
{
if (isset($search) && (trim($search)==\"\") )
{
echo \"<meta http-equiv=\\\"Refresh\\\" content=\\\"0; url=advanced_search.php?error=1\\\">\";
exit();
}
if (!$short && !$news && !$title )
{
echo \"<meta http-equiv=\\\"Refresh\\\" content=\\\"0; url=advanced_search.php?error=2\\\">\";
exit();
}
else
{
setcookie(\"cookie_advancesearch\",\"advancesearch\",time()+3600);
setcookie(\"cookie_search\",$search,time()+3600);
setcookie(\"cookie_short\",$short,time()+3600);
setcookie(\"cookie_news\",$news,time()+3600);
setcookie(\"cookie_title\",$title,time()+3600);
setcookie(\"cookie_archive\",$archive,time()+3600);
setcookie(\"cookie_catagory_id\",$catagory_id,time()+3600);
}
}
else if ($searching)
{
setcookie(\"cookie_advancesearch\",\"\",time()-3600);
setcookie(\"cookie_short\",\"\",time()-3600);
setcookie(\"cookie_search\",$search,time()+3600);
setcookie(\"cookie_news\",\"\",time()-3600);
setcookie(\"cookie_title\",\"\",time()-3600);
setcookie(\"cookie_archive\",\"\",time()-3600);
setcookie(\"cookie_catagory_id\",\"\",time()-3600);
unset($advancesearch);
unset($short);
unset($news);
unset($title);
unset($archive);
unset($catagory_id);
echo $searching;
}
else if($clean==1)
{
setcookie(\"cookie_advancesearch\",\"\",time()-3600);
setcookie(\"cookie_short\",\"\",time()-3600);
setcookie(\"cookie_search\",$search,time()+3600);
setcookie(\"cookie_news\",\"\",time()-3600);
setcookie(\"cookie_title\",\"\",time()-3600);
setcookie(\"cookie_archive\",\"\",time()-3600);
setcookie(\"cookie_catagory_id\",\"\",time()-3600);
}
include(\"head.inc.php\");
echo \"<table width=100%>\";
echo \"<tr><td align=center>\";
include_once(\"news.inc\");
include_once(\"text_format.inc\");
include_once(\"database.inc.php\");
include_once(\"common.inc.php\");
include_once(\"admin/common.inc.php\");
include_once(\"admin/language/\".$language.\"_show_news.php\");
if (isset($search))
{
$search=rawurldecode($search);
}
//if (!$search && !$cookie_search)
if (($catagory_id && $back!=1) || $show_n_id)
{
//geting Catagory info including template data function located in common.inc.php
$data=get_cat_info($catagory_id,$show_n_id);
$catagory_id=$data[0];
$show_news_template=$data[1];
$use_comments=$data[2];
$use_rate=$data[3];
$news_catagory_name=$data[4];
$show_arvhive=$data[5];
$show_more=$data[6];
$show_news=$data[7];
// done getting the catagory info
}
else
{
$show_news_template=$search_template;
$show_news=$search_limit;
$show_more=\"Y\";
$use_comments=\"Y\";
$use_rate=\"N\";
}
// this takes care of rating
if ($rate_nid && ($rate_it!=0))
{
// logs a user rate function located in common.inc.php
rate_news($REMOTE_ADDR,$rate_nid,$rate_it);
}
// this takes care of storing comments
if ($my_comment)
{
// logs a user comment function located in common.inc.php
save_comments($REMOTE_ADDR,$name,$email,$my_comment,$show_n_id);
}
// keeps track of who is reading it.
if ($show_n_id)
{
// logs a user reading news function located in common.inc.php
read_counter($REMOTE_ADDR,$show_n_id) ;
}
if (!$catagory_id && !$search && !$cookie_search)
{
echo \"Setup error Invalid catagory \'$catagory\' please check spelling\";
}
else
{
/*This is what dispays the current catagory at the top of a news section
if you dont want this you can remove the following line */
if (!$advancesearch && !$search )
{
//echo \"$news_catagory_text - \".$news_catagory_name;
if ($show_arvhive==\"Y\")
{
//echo \"<br><a href=show_news.php?catagory_id=$catagory_id&archive=1>$show_archive_text</a>\";
}
}
else
{
//echo \"$search_result_text \\\"\".$search.\"\\\"\";
}
//echo \"\\n<!--PHP-News by kill-9 from www.kill-9.dk Starting news display -->\";
// if show_news is set to 0 then we show all of the news.
if (($show_news!=0) && !$show_n_id)
{
/* this controls the next and previous buttons also gets the limit for the sql statment */
//function located in common.inc.php
if ($old_start)
{
$start=$old_start;
}
$data=next_prev($show_news,$start,$prev);
$start=$data[0];
$end=$data[1];
$limit=$data[2];
$old_start=$data[3];
}
else
{
unset($limit);
}
if (!isset($search))
{
if ($archive==1)
{
$archive_info=\"(now() > end_date)\";
}
else
{
$archive_info=\"((now() between n_date and end_date) or end_date=\'0000-00-00 00:00:00\' or end_date is null)\";
}
// getting the total nimber of rows
$sql=\"select count(*) from news where catagory_id=$catagory_id and $archive_info and approved=\'Y\'\";
$result=@mysql_query($sql,$db);
$myrow=@mysql_fetch_array($result);
$num_rows=$myrow[0];
if (!$show_n_id)
{
// getting all the approved news and unexpired news.
$sql=\"select pic2,pic3,pic2_link,pic3_link,catagory_id, user_id,short_text, n_id,UNIX_TIMESTAMP(n_date) as my_date ,n_title, news,pic_link,n_pic,n_file from news where catagory_id=$catagory_id and $archive_info and approved=\'Y\' order by n_date desc,n_id desc $limit\";
}
else
{
// getting one single news entry
$sql=\"select pic2,pic3,pic2_link,pic3_link,catagory_id, user_id,short_text, n_id,UNIX_TIMESTAMP(n_date) as my_date ,n_title, news,pic_link,n_pic,n_file from news where n_id=$show_n_id and $archive_info and approved=\'Y\' order by n_date desc,n_id desc $limit\";
}
}
else
{
if (!$advancesearch)
{
// your basic searc option here looking for anything that matches our search.
$sql=\"select count(*) from news where ((n_title like \'%$search%\' ) or (short_text like \'%$search%\')or (news like \'%$search%\')) and approved=\'Y\'\";
$result=@mysql_query($sql,$db);
$myrow=@mysql_fetch_array($result);
$num_rows=$myrow[0];
$sql=\"select pic2,pic3,pic2_link,pic3_link,catagory_id, user_id,short_text, n_id,UNIX_TIMESTAMP(n_date) as my_date ,n_title, news,pic_link,n_pic,n_file from news where ((n_title like \'%$search%\' ) or (short_text like \'%$search%\')or (news like \'%$search%\'))and approved=\'Y\' order by n_date desc,n_id desc $limit\";
}
else
{
// ok here we have advnaced search.
if ($short)
{
$text[]=\" (short_text like \'%$search%\') \";
}
if ($news)
{
$text[]=\" (news like \'%$search%\') \";
}
if ($catagory_id!=\"all\")
{
$cat=\" catagory_id =$catagory_id \";
}
if ($archive==\"old\")
{
$text[]=\" (n_date > \'now()\') \";
}
if ($archive==\"new\")
{
$text[]=\" ((end_date < \'now()\')(or end_date==\'0000-00-00 00:00:00\')) \";
}
if (count($text)!=1)
{
$where=implode(\" or \",$text);
}
else
{
$where=$text[0];
}
$sql=\"select count(*) from news where ( $where ) \";
if ($cat)
{
$sql.=\"and \".$cat;
}
$result=@mysql_query($sql,$db);
$myrow=@mysql_fetch_array($result);
$num_rows=$myrow[0];
$sql=\"select catagory_id, user_id,short_text, n_id,UNIX_TIMESTAMP(n_date) as my_date ,n_title, news,pic_link,n_pic,n_file from news where ( $where ) \";
if ($cat)
{
$sql.=\"and \".$cat;
}
}
}
// table template problem for advanced search
// need to fix the links with a dinampic varable to keep track for the back and next prev butto//ns.
//$show_news_template.=\"table.tmpl\";
$data = fread(fopen($show_news_template, \"r\"), filesize($show_news_template));
$result=@mysql_query($sql,$db);
if ($search)
{
$search_result_text=str_replace(\"{search_text}\",$search,$search_result_text);
$search_result_text=str_replace(\"{num_results}\",$num_rows,$search_result_text);
echo \"$search_result_text\";
}
while ($myrow=@mysql_fetch_array($result))
{
$n_id=$myrow[\"n_id\"];
$avrage_rate=get_reat($n_id);
$catagory_id=$myrow[\"catagory_id\"];
$n_date=date($date_format,$myrow[\"my_date\"]);
$end_date=$myrow[\"end_date\"];
$news=trim($myrow[\"news\"]);
$pic_link=$myrow[\"pic_link\"];
$picture=$myrow[\"n_pic\"];
$pic2_link=$myrow[\"pic2_link\"];
$picture2=$myrow[\"pic2\"];
$pic3_link=$myrow[\"pic_link\"];
$picture3=$myrow[\"pic3\"];
$topic=$myrow[\"n_title\"];
$file=$myrow[\"n_file\"];
$short_text=$myrow[\"short_text\"];
$topic=stripslashes($topic);
$news=stripslashes($news);
$short_text=stripslashes($short_text);
// modified by Alzir (alzir@free.fr) 2001-07-03
// better text formating.
$news=format_text($news);
$short_text=format_text($short_text);
// getting information about the author of the news.
$user_id=$myrow[\"user_id\"];
$user_data=who($myrow[\"user_id\"]);
$author=$user_data[0];
$author_email=$user_data[1];
$show_email=$user_data[2];
// getting the count of how much the news has been read
$sql=\"select count(*) from news_read where n_id=$n_id\";
$read=@mysql_query($sql,$db);
$mycount=@mysql_fetch_array($read);
$read_count=$mycount[0];
// removed for change made by alzir 2001-07-03
// replaceing urls and emails
// function found in common.inc.php
//$news=replace_email_url($news);
//$short_text=replace_email_url($short_text);
if (!$end_date)
{
$end_date=\"\";
}
$hold=$data;
// starting the replace stuff now
$hold=str_replace(\"{author}\",$author,$hold);
if ($show_email==\"Y\")
{
$hold=str_replace(\"{author_name_or_email}\",\"<a href=\\\"mailto:\".$author_email.\"\\\">\".$author.\"</a>\",$hold);
}
else
{
$hold=str_replace(\"{author_name_or_email}\",$author,$hold);
}
$hold=str_replace(\"{author_email}\",$author_email,$hold);
$hold=str_replace(\"{start_date}\",$n_date,$hold);
$hold=str_replace(\"{end_date}\",$end_date,$hold);
$hold=str_replace(\"{read_count}\",$read_count_text.\" \".$read_count,$hold);
$hold=str_replace(\"{news_number}\",$n_id,$hold);
$hold=str_replace(\"{topic}\",$topic,$hold);
$hold=str_replace(\"{news_id}\",$n_id,$hold);
$hold=str_replace(\"{user_info}\",\"<a href=users.php?user_id=\".$user_id.\">user info</a>\",$hold);
// here is where we turn off the comments if this catagory isnt suposed to have comments.
if (!$comment_flag && ($use_comments==\"Y\"))
{
$hold=str_replace(\"{comment}\",\"<a href=show_news.php?show_n_id=$n_id&comment_flag=1&archive=$archive>$comments_text</a>\",$hold);
$sql_count=\"select * from news_comment where n_id=$n_id\";
$result_comments=@mysql_query($sql_count,$db);
$total_comments=mysql_num_rows($result_comments);
$hold=str_replace(\"{comment_count}\",$total_comments,$hold);
}
else
{
$hold=str_replace(\"{comment}\",\"\",$hold);
if ($user_comments==\"Y\")
{
$sql_count=\"select * from news_comment where n_id=$n_id\";
$result_comments=@mysql_query($sql_count,$db);
$total_comments=mysql_num_rows($result_comments);
$hold=str_replace(\"{comment_count}\",$total_comments,$hold);
}
else
{
$hold=str_replace(\"{comment_count}\",\"\",$hold);
}
}
if ($old_start)
{
$pos=\"&old_start=\".$old_start;
}
if ($show_n_id && (!$comment_flag))
{
// if the picked the news then we need to replace readmore with a back button
$hold=str_replace(\"{short_news}\",\"\",$hold);
$hold=str_replace(\"{news}\",$news,$hold);
if ($cookie_search)
{
$back=\"&back=1\";
}
$hold=str_replace(\"{read_more}\",\"<a href=show_news.php?catagory_id=\".$myrow[\"catagory_id\"].$pos.\"&archive=\".$archive.\"$back>$back_text</a>\",$hold);
}
else
{
// first page.
if ($news!=\"\")
{
$hold=str_replace(\"{read_more}\",\"<a href=show_news.php?show_n_id=\".$n_id.$pos.\"&archive=\".$archive.\">$read_more_text</a>\",$hold);
}
else
{
$hold=str_replace(\"{read_more}\",\"\",$hold);
}
$hold=str_replace(\"{news}\",\"\",$hold);
$hold=str_replace(\"{short_news}\",$short_text,$hold);
}
if ($use_rate==\"Y\")
{
// the rating system form found in common.inc.php
$rating_form=make_rate_select($n_id,$show_n_id,$catagory_id,$rate_it_text);
$build_it=\"$rate_it_text \".$rating_form.\" $avrage_rate_text \".$avrage_rate;
$hold=str_replace(\"{rate_it}\",$build_it,$hold);
}
else
{
$hold=str_replace(\"{rate_it}\",\"\",$hold);
$hold=str_replace(\"{avrage_rate}\",$avrage_rate,$hold);
}
// for picture
if ($picture)
{
if ($pic_link)
{
$hold=str_replace(\"{picture}\",\"<a href=\\\"$pic_link\\\" target=_new><img src=upload/\".$picture.\" align=\\\"right\\\" border=0></a>\",$hold);
}
else
{
$hold=str_replace(\"{picture}\",\"<img align=\\\"right\\\" border=\\\"0\\\" src=\\\"upload/\".$picture.\"\\\">\",$hold);
}
}
else
{
$hold=str_replace(\"{picture}\",\"\",$hold);
}
if ($picture2)
{
if ($pic2_link)
{
$hold=str_replace(\"{picture2}\",\"<a href=\\\"$pic2_link\\\" target=_new><img src=upload/\".$picture2.\" align=\\\"right\\\" border=0></a>\",$hold);
}
else
{
$hold=str_replace(\"{picture2}\",\"<img align=\\\"right\\\" border=\\\"0\\\" src=\\\"upload/\".$picture2.\"\\\">\",$hold);
}
}
else
{
$hold=str_replace(\"{picture2}\",\"\",$hold);
}
if ($picture3)
{
if ($pic3_link)
{
$hold=str_replace(\"{picture3}\",\"<a href=\\\"$pic3_link\\\" target=_new><img src=upload/\".$picture3.\" align=\\\"right\\\" border=0></a>\",$hold);
}
else
{
$hold=str_replace(\"{picture3}\",\"<img align=\\\"right\\\" border=\\\"0\\\" src=\\\"upload/\".$picture3.\"\\\">\",$hold);
}
}
else
{
$hold=str_replace(\"{picture3}\",\"\",$hold);
}
// done picture
if ($file)
{
$hold=str_replace(\"{file}\",\"<a href=\\\"upload/\".$file.\" \\\"target=_new>$file</a>\",$hold);
}
else
{
$hold=str_replace(\"{file}\",\"\",$hold);
}
echo $hold;
}
echo \"</td></tr>\";
if (!$show_n_id && ($show_more==\"Y\"))
{
echo \"<tr><td align=center>\";
$stop=$start+$show_news;
if ($search)
{
$search=rawurlencode($search);
}
if ($stop>$num_rows)
{
$stop=$num_rows;
}
$start_point=$start+1;
if ($num_rows==0)
{
if (!$search)
{
$showing= $showing_no_news;
}
else
{
$showing= $search_no_news;
}
}
else
{
$showing=\"$showing_text $start_point - $stop $showing_total_text $num_rows<br>\";
}
echo $showing;
if ($start!=0)
{
echo \"<a href=show_news.php?prev=$start&catagory_id=$catagory_id&search=$search>$prev_text</a> \";
}
if ($num_rows> $stop )
{
echo \"<a href=show_news.php?start=$start&catagory_id=$catagory_id&search=$search>$next_text</a>\";
}
}
echo \"</td></tr>\";
}
echo \"</table>\";
if ($show_n_id)
{
echo \"<center>\";
$data = fread(fopen(\"templates/comments.tmpl\", \"r\"), filesize(\"templates/comments.tmpl\"));
$sql=\"select name,email,comment,UNIX_TIMESTAMP(stamp) as stamp from news_comment where n_id=$show_n_id order by stamp\";
$result=@mysql_query($sql,$db);
while ($myrow=@mysql_fetch_array($result))
{
$hold=$data;
$name=$myrow[\"name\"];
$email=$myrow[\"email\"];
$comment=$myrow[\"comment\"];
$post_date=$myrow[\"stamp\"];
$comment=str_replace(\""\",\"\\\"\",$comment);
$comment=str_replace(\"´\",\"\'\",$comment);
// modified by Alzir (alzir@free.fr) 2001-07-03
// better text formating.
$comment=format_text ($comment);
// removed for change made by alzir 2001-07-03
//$comment=htmlspecialchars ($comment);
//$comment=nl2br($comment);
// fixing bug for date formating in comments 2001-07-03 kill-9
$stamp=date($date_format_comment,$post_date);
$hold=str_replace(\"{author}\",$name,$hold);
$hold=str_replace(\"{start_date}\",$stamp,$hold);
$hold=str_replace(\"{comment}\",$comment,$hold);
echo $hold;
}
echo \"</center>\";
}
if ($comment_flag==1)
{
include_once(\"admin/table.inc.php\");
$str=create_table_top(300,$table_color,$post_comment_table_text);
echo $str;
echo \"<form action=show_news.php method=post>\";
echo \"<table width=500 border=0 cellspacing=0> \";
echo \"<tr><td>$name_text<br><input type=text name=name size=40></td></tr>\";
echo \"<tr><td>$email_text <br> <input type=text name=email size=40></td></tr>\";
echo \"<tr><td>$comment_text <br> <textarea name=my_comment cols=40 rows=10></textarea></td></tr>\";
echo \"<tr><td><input type=hidden name=show_n_id value=$show_n_id>
<input type=submit name=submit value=\'$post_comment_text\'><input type=reset name=reset value=\'$reset_form_text\'></td></tr>\";
echo \"</table>\";
echo \"</form>\";
$str=create_table_bottom();
echo $str;
}
echo \"\\n<!--PHP-News by kill-9 from www.kill-9.dk End news display -->\";
include(\"foot.inc.php\");
?>