Gem Posted April 5, 2009 Share Posted April 5, 2009 I wonder if you can help I have a table (id, title, subtitle, article) and at the moment, I have each "row" displayed on a different "page" using the pagination codeI found. This works great but I want to change it. Basically what I want to do is on the news.php page, is list titles/subtitle ... and when you click on the title, you are moved to the article itself ... Hope that makes sense. Im really new to php and im learning as I go ... can anyone help me out with how I code it to do that? Thanks a million Gem OK heres what I have so far: www.bradleystokejudoclub.co.uk/news.php and heres the code: <!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> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>::Bradley Stoke Judo Club::News::</title> <meta name="keywords" content="judo, bradley, stoke, bradley stoke, judo club, club" /> <meta name="description" content="The Website of Bradley Stoke Judo Club, Bristol, UK." /> <link href="default.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .menutitle{ cursor:pointer; margin-bottom: 5px; background-color:#ffff00; color:#000000; width:140px; padding:2px; text-align:center; font-weight:bold; /*/*/border:1px solid #000000;/* */ } .submenu{ margin-bottom: 0.5em; text-color:#ffff00; font-weight:bold; } </style> <script type="text/javascript"> var persistmenu="yes" var persisttype="sitewide" if (document.getElementById){ document.write('<style type="text/css">\n') document.write('.submenu{display: none;}\n') document.write('</style>\n') } function SwitchMenu(obj){ if(document.getElementById){ var el = document.getElementById(obj); var ar = document.getElementById("masterdiv").getElementsByTagName("span"); if(el.style.display != "block"){ //DynamicDrive.com change for (var i=0; i<ar.length; i++){ if (ar[i].className=="submenu") ar[i].style.display = "none"; } el.style.display = "block"; }else{ el.style.display = "none"; } } } function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) if (offset != -1) { offset += search.length end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; } function onloadfunction(){ if (persistmenu=="yes"){ var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname var cookievalue=get_cookie(cookiename) if (cookievalue!="") document.getElementById(cookievalue).style.display="block" } } function savemenustate(){ var inc=1, blockid="" while (document.getElementById("sub"+inc)){ if (document.getElementById("sub"+inc).style.display=="block"){ blockid="sub"+inc break } inc++ } var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid document.cookie=cookiename+"="+cookievalue } if (window.addEventListener) window.addEventListener("load", onloadfunction, false) else if (window.attachEvent) window.attachEvent("onload", onloadfunction) else if (document.getElementById) window.onload=onloadfunction if (persistmenu=="yes" && document.getElementById) window.onunload=savemenustate </script> <SCRIPT LANGUAGE="JavaScript"> function loadImages() { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('hidepage').style.visibility = 'hidden'; } else { if (document.layers) { // Netscape 4 document.hidepage.visibility = 'hidden'; } else { // IE 4 document.all.hidepage.style.visibility = 'hidden'; } } } </script> </head> <BODY OnLoad="loadImages()"> <div id="hidepage" style="position: absolute; left:300px; top:150px; right:5px; bottom:5px; background-color: #FFFF00; layer-background-color: #FFFFCC; height: 50%; width: 50%;"> <table width=100%><tr><td><font size="5" face="ariel"><BR><BR><CENTER><IMG SRC="images/bradstokelogo.jpg" width="110" height="120"><BR>Welcome to Bradley Stoke Judo Club <BR>Please Wait whilst this page loads ...</CENTER></font></td></tr></table></div> <div id="wrapper"> <div id="header"> <h1></h1> <h2></h2> <hr /> </div> <div id="content"> <div id="content1"> <div id="post-1" class="post"> <h2 class="title"> !Celebrating Our 10th Anniversary - 2009!</h2> <div class="entry"> <center> <H1>Latest News</H1><BR> Use the Navigation Links at the bottom of this article to read through other entries... <BR><BR> <?php // database connection info $conn = mysql_connect("80.94.196.33","USERNAME","PASSWORD") or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('bssql',$conn) or trigger_error("SQL", E_USER_ERROR); // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM articles"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 1; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $sql = "SELECT title, subtitle, article FROM articles ORDER BY ID DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) { // echo data ?><H2><?php echo nl2br($list['title']); ?> </H2> <H3><?php echo nl2br($list['subtitle']); ?> </H3> <?php echo nl2br($list['article']); echo "<br />##########################################"; echo "<br /><br />"; } // end while /****** build the pagination links ******/ // range of num links to show $range = 4; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?> </div> <div class="hr"> <hr /> </div> </div> <!-- end #post-1 --> <!-- end #post-2 --> </div> <!-- end #blog --> <div id="sidebar"> <ul> <li id="search"> <h2>Navigate the Site</h2> <BR> <div id="masterdiv" align="center"> <div class="menutitle" onclick="SwitchMenu('sub1')">About BSJC</div> <span class="submenu" id="sub1"> <a href="aboutus.php">About Us</a><br> <a href="joinus.php">Join Us</a><br> </span> <div class="menutitle" onclick="SwitchMenu('sub2')">Contact Us</div> <span class="submenu" id="sub2"> <a href="contact.php">Contact Form</a><br> <a href="guestbook/gbook.php" target="_new">Guestbook</a><br> <a href="mailto:[email protected]">Email Webmaster</a> </span> <div class="menutitle" onclick="SwitchMenu('sub3')">Club News</div> <span class="submenu" id="sub3"> <a href="news.php">News</a><br> <a href="diary.php">Diary</a><br> <a href="roh.php">Roll of Honour</a> </span> <div class="menutitle" onclick="SwitchMenu('sub4')">Members Stuff</div> <span class="submenu" id="sub4"> <a href="grading.php">Grading Information</a><br> <a href="rules.php">Club Rules</a><br> <a href="videos.php">Videos</a> </span> <div class="menutitle" onclick="SwitchMenu('sub5')">Gallery</div> <span class="submenu" id="sub5"> <a href="jalbum/" target="_new">2008-2009 Pictures</a><br> <a href="archivegallery.php">Archived Pictures</a> </span> <div class="menutitle" onclick="SwitchMenu('sub6')">Merchandise</div> <span class="submenu" id="sub6"> <a href="merchandise.php">Price List</a><br> <a href="orderform.php">Order</a> </span> <div class="menutitle" onclick="SwitchMenu('sub7')">Special Needs</div> <span class="submenu" id="sub7"> - <a href="http://www.specialneeds.bradleystokejudoclub.co.uk/" target="main">Special Needs Website</a><br> </span> <div class="menutitle" onclick="SwitchMenu('sub8')">Links</div> <span class="submenu" id="sub8"> - <a href="http://www.britishjudo.org.uk" target="_blank">British Judo Association</a><br> - <a href="http://www.judoinfo.com" target="_blank">Judoinfo.com</a><br> - <a href="http://www.judoforum.com" target="_blank">Judoforum.com</a><br> - <a href="links.php">Other</a> </span> </div> </li> <!-- end navigation --> <li id="archives" align="center"> <h2>Quick Links</h2> <ul> <a href="index.php"><H3>Home</H3></a> <a href="guestbook/gbook.php" target="_new"><H3>Guest Book</H3></a> <a href="forum"><H3>BSJC Forum</H3></a> <BR> </ul> </li> <!-- end #archives --> <li id="categories"> <h2>Member Club 2009</h2> <ul> <CENTER> <IMG SRC="images/BJA.jpg"> </CENTER> </ul> </li> <!-- end #categories --> <li id="blogroll"> <h2>Sponsered By</h2> <center><IMG SRC="images/proemblogo.jpg"></center> </li> <!-- end #blogroll --> </ul> </div> <!-- end #sidebar --> <div style="clear: both; height: 1px;"></div> </div> <!-- end #content --> <div id="footer"> <p>© Copyright 2009 Bradley Stoke Judo Club. Site designed by Gem Gale - <A HREF="contact.php">Contact</A> </div> </div> <!-- end #wrapper --> </body> </html> Link to comment https://forums.phpfreaks.com/topic/152659-on-click-echo/ Share on other sites More sharing options...
Gem Posted April 5, 2009 Author Share Posted April 5, 2009 bump Link to comment https://forums.phpfreaks.com/topic/152659-on-click-echo/#findComment-801725 Share on other sites More sharing options...
revraz Posted April 5, 2009 Share Posted April 5, 2009 Try the Javascript forums, this is for PHP. Link to comment https://forums.phpfreaks.com/topic/152659-on-click-echo/#findComment-801728 Share on other sites More sharing options...
Gem Posted April 5, 2009 Author Share Posted April 5, 2009 I didnt know it was a javascript problem?? I will try there then Link to comment https://forums.phpfreaks.com/topic/152659-on-click-echo/#findComment-801731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.