Boxerman Posted December 12, 2010 Share Posted December 12, 2010 Hi, Im a little confused on how to go about setting up a news section. i.e On my homepage i got it displaying Title: Postedby: brief: i would like a read more button... So it will go around index.php?news=$idfullstory (something like that) and on that page it will automatically show the full story etc.. Just a bit confused, so can someone break it down or even better point me in the right direction please? Thanks, J Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/ Share on other sites More sharing options...
litebearer Posted December 12, 2010 Share Posted December 12, 2010 You could use something like here http://www.dhtmlgoodies.com/index.html?whichScript=show_hide_content_slide Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146139 Share on other sites More sharing options...
Boxerman Posted December 12, 2010 Author Share Posted December 12, 2010 Im just after a bog standard one pal... Im got a blank page... just confused on how to call the info onto that page etc.. Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146140 Share on other sites More sharing options...
litebearer Posted December 12, 2010 Share Posted December 12, 2010 Show us your existing code Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146144 Share on other sites More sharing options...
Boxerman Posted December 12, 2010 Author Share Posted December 12, 2010 Thats what i need help with.. At the moment my homepage is something a short version... I've made a page called story.php i want it to be like story.php?id=1 and that will grab all the news for id 1 and then story.php?id=2 will just grab all news for id number 2 etc.. Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146145 Share on other sites More sharing options...
litebearer Posted December 12, 2010 Share Posted December 12, 2010 Untested, un-proofread BUT it should at the least point you in the right direction... <?PHP /* function to return the first N words of a string */ function shorten_string($string, $wordsreturned) { $retval = $string; $array = explode(" ", $string); if (count($array)<=$wordsreturned) { $retval = $string; }else{ array_splice($array, $wordsreturned); $retval = implode(" ", $array)." ..."; } return $retval; } /* connect to db */ include ('db.php'); /* create query */ $query = "SELECT * FROM table_name ORDER BY date"; /* execute the query */ $result = mysql_query($query); /* check to see if an article has been selected */ if(!$_GET['article_id']) { $article_id = 0; }else{ $article_id = (int) $_GET['article_id']; } /* set the number of words for the brief */ $N = 15; /* loop thru the results */ while($row=mysql_fetch_array($result)) { $title = $row['title']; $posted_by = $row['postedby']; $brief = shorten_string($row['article_content'], $N) ?> Title: <?PHP echo $title; ?> <br> Posted By: <?PHP echo $posted_by; ?> <br> <a href="index.php?article_id=<?PHP echo row['id']; ?>"><?PHP echo $brief']; ?></a> <?PHP if($article_id == $row['id']) { echo "<br>" . $row['article_content'] . "<hr>"; }else{ echo "<br>"; } } Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146148 Share on other sites More sharing options...
Boxerman Posted December 12, 2010 Author Share Posted December 12, 2010 Still confused.. as it is not working :S This is my full site code: <?php include("include/config.inc.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="style.css" type="text/css" /> <title></title> <script language='javascript' type='text/javascript'> <!-- var win=null; function NewWindow(mypage,myname,w,h,pos,infocus){ if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;} if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;} else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20} settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=yes,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings); win.focus();} // --> </script> </head> <body> <div id="header"></div> <div id="container"> <ul id="topmenu"> <li><a href="index.php">Home index</a></li> <li>-</li> <li><a href="contact.php">Contact Us</a></li> <li>-</li> <li><a href="report.php">Report A Error</a></li> </ul> <div id="menucontent"> <div id="links"> <div id="menu"> <h3>Menu</h3> <ul id="linksmenu"> <li><a href="index.php">Home</a></li> <li><a href="request.php">Request</a></li> <li><a href="chart.php">Chart</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');"> mini versie </a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Media</h3> <ul id="linksmenu"> <li><a href="music.php">Music</a></li> <li><a href="videos.php">Videos</a></li> <li><a href="http://facebook.com/truvibefm" target="_blank">Facebook</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');">Player</a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Link</h3> <ul id="linksmenu"> <li></li> <li></li> <li></li> </ul> <div id="menulast"></div> </div> </div> <div id="rechts"> <div id="rechtscontent"> <h2></h2> <ul> <p><?PHP /* function to return the first N words of a string */ function shorten_string($string, $wordsreturned) { $retval = $string; $array = explode(" ", $string); if (count($array)<=$wordsreturned) { $retval = $string; }else{ array_splice($array, $wordsreturned); $retval = implode(" ", $array)." ..."; } return $retval; } /* connect to db */ include ('include/config.inc.php'); /* create query */ $query = "SELECT * FROM news ORDER BY id"; /* execute the query */ $result = mysql_query($query); /* check to see if an article has been selected */ if(!$_GET['id']) { $id = 0; }else{ $id = (int) $_GET['id']; } /* set the number of words for the brief */ $N = 15; /* loop thru the results */ while($row=mysql_fetch_array($result)) { $title = $row['title']; $posted_by = $row['postedby']; $text = shorten_string($row['text'], $N) ?> Title: <?PHP echo $title; ?> <br> Posted By: <?PHP echo $posted_by; ?> <br> <a href="index.php?id=<?PHP echo row['id']; ?>"><?PHP echo row['$text']; ?></a> <?PHP if($id == $row['id']) { echo "<br>" . $row['text'] . "<hr>"; }else{ echo "<br>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146153 Share on other sites More sharing options...
OOP Posted December 12, 2010 Share Posted December 12, 2010 I guess, it would be good if you can have two files: 1- Main.php : this will show a list of all news in a short version 2- newsDetails.php: this is to show the full version of the selected news Then in the main.php your link should point to newsDetails.php?id={selected_news_id} Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146159 Share on other sites More sharing options...
litebearer Posted December 12, 2010 Share Posted December 12, 2010 Define 'not working'. Which part is not working? Also tho you state... This is my full site code: the last portion of your script is missing Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146160 Share on other sites More sharing options...
litebearer Posted December 12, 2010 Share Posted December 12, 2010 BTW a site (not a GREAT site) that does a similar thing... http://wljol.com/ Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146162 Share on other sites More sharing options...
Boxerman Posted December 12, 2010 Author Share Posted December 12, 2010 what last bit of my script? thats the whole page. and its not displaying anything... its just a white page :S Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146171 Share on other sites More sharing options...
litebearer Posted December 12, 2010 Share Posted December 12, 2010 the portion you are showing does NOT close the last div nor the last <ul>. look closely at what you have posted above Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146173 Share on other sites More sharing options...
Boxerman Posted December 12, 2010 Author Share Posted December 12, 2010 Just looked at script and i needed to edit: <a href="index.php?id=<?PHP echo row['id']; ?>"><?PHP echo row['$text']; ?></a> so i fixed that.. now it displays and works. if i wanted to link all i would need is to add <?PHP echo row['id']; ?> ? Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146176 Share on other sites More sharing options...
Boxerman Posted December 12, 2010 Author Share Posted December 12, 2010 Hi, when using this code: <?php include("include/config.inc.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="style.css" type="text/css" /> <title></title> <script language='javascript' type='text/javascript'> <!-- var win=null; function NewWindow(mypage,myname,w,h,pos,infocus){ if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;} if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;} else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20} settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=yes,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings); win.focus();} // --> </script> </head> <body> <div id="header"></div> <div id="container"> <ul id="topmenu"> <li><a href="index.php">Home index</a></li> <li>-</li> <li><a href="contact.php">Contact Us</a></li> <li>-</li> <li><a href="report.php">Report A Error</a></li> </ul> <div id="menucontent"> <div id="links"> <div id="menu"> <h3>Menu</h3> <ul id="linksmenu"> <li><a href="index.php">Home</a></li> <li><a href="request.php">Request</a></li> <li><a href="chart.php">Chart</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');"> mini versie </a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Media</h3> <ul id="linksmenu"> <li><a href="music.php">Music</a></li> <li><a href="videos.php">Videos</a></li> <li><a href="http://facebook.com/truvibefm" target="_blank">Facebook</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');">Player</a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Link</h3> <ul id="linksmenu"> <li></li> <li></li> <li></li> </ul> <div id="menulast"></div> </div> </div> <div id="rechts"> <div id="rechtscontent"> <h2></h2> <ul> <p><?PHP /* function to return the first N words of a string */ function shorten_string($string, $wordsreturned) { $retval = $string; $array = explode(" ", $string); if (count($array)<=$wordsreturned) { $retval = $string; }else{ array_splice($array, $wordsreturned); $retval = implode(" ", $array)." ..."; } return $retval; } /* create query */ $query = "SELECT * FROM news ORDER BY id"; /* execute the query */ $result = mysql_query($query); /* check to see if an article has been selected */ if(!$_GET['id']) { $id = 0; }else{ $id = (int) $_GET['id']; } /* set the number of words for the brief */ $N = 15; /* loop thru the results */ while($row=mysql_fetch_array($result)) { $title = $row['title']; $posted_by = $row['postedby']; $brief = shorten_string($row['text'], $N) ?> Title: <?PHP echo $title; ?> <br> Posted By: <?PHP echo $posted_by; ?> <br> <a href="story.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $brief; ?></a> <? } ?> When i click link to story.php?id=2 it is displaying all the news not just id=2? Have i done something wrong? Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146381 Share on other sites More sharing options...
litebearer Posted December 12, 2010 Share Posted December 12, 2010 where is this ... if($id == $row['id']) { echo "<br>" . $row['text'] . "<hr>"; }else{ echo "<br>"; } AND because you have NOT included the remainder of your code, we cannot see if have properly closed your div and UL's Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146389 Share on other sites More sharing options...
Boxerman Posted December 12, 2010 Author Share Posted December 12, 2010 That is the full code! promise! it calls header.php which contains most of the coding... and i added that part in which still displaying all <?php include("include/config.inc.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="style.css" type="text/css" /> <title></title> <script language='javascript' type='text/javascript'> <!-- var win=null; function NewWindow(mypage,myname,w,h,pos,infocus){ if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;} if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;} else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20} settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=yes,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings); win.focus();} // --> </script> </head> <body> <div id="header"></div> <div id="container"> <ul id="topmenu"> <li><a href="index.php">Home index</a></li> <li>-</li> <li><a href="contact.php">Contact Us</a></li> <li>-</li> <li><a href="report.php">Report A Error</a></li> </ul> <div id="menucontent"> <div id="links"> <div id="menu"> <h3>Menu</h3> <ul id="linksmenu"> <li><a href="index.php">Home</a></li> <li><a href="request.php">Request</a></li> <li><a href="chart.php">Chart</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');"> mini versie </a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Media</h3> <ul id="linksmenu"> <li><a href="music.php">Music</a></li> <li><a href="videos.php">Videos</a></li> <li><a href="http://facebook.com/truvibefm" target="_blank">Facebook</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');">Player</a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Link</h3> <ul id="linksmenu"> <li></li> <li></li> <li></li> </ul> <div id="menulast"></div> </div> </div> <div id="rechts"> <div id="rechtscontent"> <h2></h2> <ul> <p><?PHP /* function to return the first N words of a string */ function shorten_string($string, $wordsreturned) { $retval = $string; $array = explode(" ", $string); if (count($array)<=$wordsreturned) { $retval = $string; }else{ array_splice($array, $wordsreturned); $retval = implode(" ", $array)." ..."; } return $retval; } /* create query */ $query = "SELECT * FROM news ORDER BY id"; /* execute the query */ $result = mysql_query($query); /* check to see if an article has been selected */ if(!$_GET['id']) { $id = 0; }else{ $id = (int) $_GET['id']; } /* set the number of words for the brief */ $N = 15; /* loop thru the results */ while($row=mysql_fetch_array($result)) { $title = $row['title']; $posted_by = $row['postedby']; $brief = shorten_string($row['text'], $N) ?> Title: <?PHP echo $title; ?> <br> Posted By: <?PHP echo $posted_by; ?> <br> <a href="story.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $brief; ?></a> <?PHP if($article_id == $row['id']) { echo "<br>" . $row['text'] . "<hr>"; }else{ echo "<br>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146393 Share on other sites More sharing options...
litebearer Posted December 13, 2010 Share Posted December 13, 2010 I made a few changes, copy and paste this in its entirety... <?php include("include/config.inc.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="style.css" type="text/css" /> <title></title> <script language='javascript' type='text/javascript'> <!-- var win=null; function NewWindow(mypage,myname,w,h,pos,infocus){ if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;} if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;} else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20} settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=yes,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings); win.focus();} // --> </script> </head> <body> <div id="header"></div> <div id="container"> <ul id="topmenu"> <li><a href="index.php">Home index</a></li> <li>-</li> <li><a href="contact.php">Contact Us</a></li> <li>-</li> <li><a href="report.php">Report A Error</a></li> </ul> <div id="menucontent"> <div id="links"> <div id="menu"> <h3>Menu</h3> <ul id="linksmenu"> <li><a href="index.php">Home</a></li> <li><a href="request.php">Request</a></li> <li><a href="chart.php">Chart</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');"> mini versie </a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Media</h3> <ul id="linksmenu"> <li><a href="music.php">Music</a></li> <li><a href="videos.php">Videos</a></li> <li><a href="http://facebook.com/truvibefm" target="_blank">Facebook</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');">Player</a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Link</h3> <ul id="linksmenu"> <li></li> <li></li> <li></li> </ul> <div id="menulast"></div> </div> </div> <div id="rechts"> <div id="rechtscontent"> <p> <?PHP /* function to return the first N words of a string */ function shorten_string($string, $wordsreturned) { $retval = $string; $array = explode(" ", $string); if (count($array)<=$wordsreturned) { $retval = $string; }else{ array_splice($array, $wordsreturned); $retval = implode(" ", $array)." ..."; } return $retval; } /* create query */ $query = "SELECT * FROM news ORDER BY id"; /* execute the query */ $result = mysql_query($query); /* check to see if an article has been selected */ if(!$_GET['id']) { $id = 0; }else{ $id = (int) $_GET['id']; } /* set the number of words for the brief */ $N = 15; /* loop thru the results */ while($row=mysql_fetch_array($result)) { $title = $row['title']; $posted_by = $row['postedby']; $brief = shorten_string($row['text'], $N); ?> Title: <?PHP echo $title; ?> <br> Posted By: <?PHP echo $posted_by; ?> <br> <a href="story.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $brief; ?></a> <?PHP if($id == $row['id']) { echo "<br>" . $row['text'] . "<hr>"; }else{ echo "<br>"; } } ?> </div> </div> </div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146439 Share on other sites More sharing options...
Boxerman Posted December 13, 2010 Author Share Posted December 13, 2010 I changed the whole code for that and when on story.php?id=90 it is still displaying all the news :S Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146638 Share on other sites More sharing options...
litebearer Posted December 13, 2010 Share Posted December 13, 2010 show your most recent code Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146647 Share on other sites More sharing options...
Boxerman Posted December 13, 2010 Author Share Posted December 13, 2010 <?php include("include/config.inc.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="style.css" type="text/css" /> <title></title> <script language='javascript' type='text/javascript'> <!-- var win=null; function NewWindow(mypage,myname,w,h,pos,infocus){ if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;} if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;} else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20} settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=yes,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings); win.focus();} // --> </script> </head> <body> <div id="header"></div> <div id="container"> <ul id="topmenu"> <li><a href="index.php">Home index</a></li> <li>-</li> <li><a href="contact.php">Contact Us</a></li> <li>-</li> <li><a href="report.php">Report A Error</a></li> </ul> <div id="menucontent"> <div id="links"> <div id="menu"> <h3>Menu</h3> <ul id="linksmenu"> <li><a href="index.php">Home</a></li> <li><a href="request.php">Request</a></li> <li><a href="chart.php">Chart</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');"> mini versie </a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Media</h3> <ul id="linksmenu"> <li><a href="music.php">Music</a></li> <li><a href="videos.php">Videos</a></li> <li><a href="http://facebook.com/truvibefm" target="_blank">Facebook</a></li> <li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');">Player</a></li> </ul> <div id="menulast"></div> </div> <div id="menu"> <h3>Link</h3> <ul id="linksmenu"> <li></li> <li></li> <li></li> </ul> <div id="menulast"></div> </div> </div> <div id="rechts"> <div id="rechtscontent"> <p> <?PHP /* function to return the first N words of a string */ function shorten_string($string, $wordsreturned) { $retval = $string; $array = explode(" ", $string); if (count($array)<=$wordsreturned) { $retval = $string; }else{ array_splice($array, $wordsreturned); $retval = implode(" ", $array)." ..."; } return $retval; } /* create query */ $query = "SELECT * FROM news ORDER BY id"; /* execute the query */ $result = mysql_query($query); /* check to see if an article has been selected */ if(!$_GET['id']) { $id = 0; }else{ $id = (int) $_GET['id']; } /* set the number of words for the brief */ $N = 15; /* loop thru the results */ while($row=mysql_fetch_array($result)) { $title = $row['title']; $posted_by = $row['postedby']; $brief = shorten_string($row['text'], $N); ?> Title: <?PHP echo $title; ?> <br> Posted By: <?PHP echo $posted_by; ?> <br> <a href="story.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $brief; ?></a> <?PHP if($id == $row['id']) { echo "<br>" . $row['text'] . "<hr>"; }else{ echo "<br>"; } } ?> </div> </div> </div> </div> </body> </html> There ya go dude. Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146648 Share on other sites More sharing options...
litebearer Posted December 13, 2010 Share Posted December 13, 2010 When you say... when on story.php?id=90 it is still displaying all the news Do you mean EVERY story is displayed in its entirety at the same time? Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146656 Share on other sites More sharing options...
Boxerman Posted December 13, 2010 Author Share Posted December 13, 2010 It displays the full story for story.php?id=90 but displays the briefs of every other story. Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146674 Share on other sites More sharing options...
litebearer Posted December 13, 2010 Share Posted December 13, 2010 So I am clear as to what is happening... when you first load the page (making sure that cache has been cleared and that $_GET['id'] is NOT 'lurking' in memory), all briefs are shown as links BUT 90 is shown in its entirety? Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146720 Share on other sites More sharing options...
Boxerman Posted December 13, 2010 Author Share Posted December 13, 2010 When i go to story.php it displays all the news i.e: Title:123 PostedBy:123 Brief:123 Read More ---- Title:456 PostedBy:456 Brief:456 Read More ---- when i click read more on ANY of the storys it just it will just be like this: Title:123 PostedBy:123 Story: sdjaskdjaksdjaksdjkasdjkasjdkasjdkjaskdjaksjd asdohya osdih aosdh aoisdh aoisdh oaisdh oasidhasd Read More ---- Title:456 PostedBy:456 Brief:456 Read More AS you can see it still displaying other news. Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146788 Share on other sites More sharing options...
litebearer Posted December 13, 2010 Share Posted December 13, 2010 Ok, so you want all links to other stories to 'disappear' when you select? Link to comment https://forums.phpfreaks.com/topic/221390-displaying-part-news-one-1-page-and-full-on-another/#findComment-1146792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.