kvnirvana Posted October 5, 2010 Share Posted October 5, 2010 Any idea why this wont work? Think it has something to with how i'm passing the variables? $latinsk =$row['latinsk'];$ID =$row['id']; //-display the result of the arrayecho "<ul>\n";echo "<li>" . "<p style='font-family:verdana;font-size:150%;'><a href='javascript:void()' onclick='window.location.href='search.php?id= '" . $ID . "'&latinsk= '" . $latinsk . "''; parent.scrollTo(0,0); return false'> " .$latinsk . " </a></li>\n</p>";echo "</ul>"; Link to comment https://forums.phpfreaks.com/topic/215214-trouble-passing-variables/ Share on other sites More sharing options...
jl5501 Posted October 5, 2010 Share Posted October 5, 2010 You have not shown where your $row array comes from. If you can show that, then we may be able to help. Link to comment https://forums.phpfreaks.com/topic/215214-trouble-passing-variables/#findComment-1119315 Share on other sites More sharing options...
Pikachu2000 Posted October 5, 2010 Share Posted October 5, 2010 It appears you have extra whitespace after ?id= and &latinsk=, and may possibly have some extra quotes in there as well. Link to comment https://forums.phpfreaks.com/topic/215214-trouble-passing-variables/#findComment-1119319 Share on other sites More sharing options...
kvnirvana Posted October 5, 2010 Author Share Posted October 5, 2010 I've now removed the extra whitespaces, but it still doesn't work. This is the full code <html><head><link rel="stylesheet" type="text/css" href="noi.css" /></head><table width='800' height=''><tr></td><body><p id="start"></p><p></p><p style='font-family:verdana;font-size:150%;'><a href="?by=A">A</a> | <a href="?by=B">B</a> | <a href="?by=C">C</a> |<a href="?by=D">D</a> | <a href="?by=E">E</a> | <a href="?by=F">F</a>| <a href="?by=G">G</a> | <a href="?by=H">H</a> |<a href="?by=I">I</a> | <a href="?by=J">J</a> | <a href="?by=K">K</a>| <a href="?by=L">L</a> | <a href="?by=M">M</a> |<a href="?by=N">N</a> | <a href="?by=O">O</a> | <a href="?by=P">P</a>| <a href="?by=Q">Q</a> | <a href="?by=R">R</a> |<a href="?by=S">S</a> | <a href="?by=T">T</a> | <a href="?by=U">U</a>| <a href="?by=V">V</a> | <a href="?by=W">W</a> |<a href="?by=X">X</a> | <a href="?by=Y">Y</a> | <a href="?by=Z">Z</a>| <a href="?by=Æ">Æ</a> | <a href="?by=Ø">Ø</a> |<a href="?by=Å">Å</a> </p></tr></td></table></body></html><?phpif ( (isset($_GET['by'])) or (isset($_GET['pg'])) ){$letter=$_GET['by'];//connect to the database$db=mysql_connect ("***", "****", "***") or die ('I cannot connect to the database because: ' . mysql_error());//-select the database to use$mydb=mysql_select_db("****");$records_per_page = 3;//-query the database table$sql1="SELECT * FROM fa WHERE latinsk LIKE '$letter%'";//-run the query against the mysql query function$result=mysql_query($sql1);//-count results$numrows=mysql_num_rows($result);$num_pages = ceil($numrows/$records_per_page);//Determine the page to display$current_page = (isset($_GET['pg']))?$_GET['pg']:1;if($current_page<1 || $current_page>$num_pages) { $current_page = 1; }//Define the limit start position for the current page of records (for current filter)$limitstart = (($current_page-1)*$records_per_page);$sql="SELECT * FROM fa WHERE latinsk LIKE '$letter%' LIMIT $limitstart, $records_per_page"; $result1=mysql_query($sql);echo "</p>";//-create while loop and loop through result setwhile($row=mysql_fetch_array($result1)){$latinsk =$row['latinsk'];$ID =$row['id']; //-display the result of the arrayecho "<ul>\n";echo "<li>" . "<p style='font-family:verdana;font-size:150%;'><a href='javascript:void()' onclick='window.location.href='search.php?id='" . $ID . "'&latinsk='" . $latinsk . "''; parent.scrollTo(0,0); return false'> " .$latinsk . " </a></li>\n</p>";echo "</ul>";}if($num_pages>1){ $thisroot = $_SERVER['PHP_SELF']; echo "<strong>Sider:</strong> "; //Create link to navigate to last page if($current_page > 1) { echo "<a href=\"{$thisroot}?pg=" . ($current_page-1) . "&by=". ($letter) . "\"><< Previous</a> \n"; } //Create individual page links for($page=1; $page<=$num_pages; $page++) { echo ($page!= $current_page) ? "<a href=\"{$thisroot}?pg={$page}&by=". ($letter) . "\">$page</a>" : $page; echo " "; } //Create link to next page if($current_page < $num_pages) { echo "<a href=\"{$thisroot}?pg=" . ($current_page+1) . "&by=". ($letter) . "\">Next >></a>"; }}}?> Link to comment https://forums.phpfreaks.com/topic/215214-trouble-passing-variables/#findComment-1119331 Share on other sites More sharing options...
kvnirvana Posted October 5, 2010 Author Share Posted October 5, 2010 Actually I made it work by doing it this way echo "<ul>\n";echo "<li>" . "<p style='font-family:verdana;font-size:150%;'><a href='javascript:void()' onclick='window.location.href=\"search.php?id=" . ($ID) . "&latinsk=". ($latinsk) . "\"; parent.scrollTo(0,0); return false'> " .$latinsk . " </a></li>\n</p>";echo "</ul>"; Is this the right way to do it, or is there a better way? Link to comment https://forums.phpfreaks.com/topic/215214-trouble-passing-variables/#findComment-1119336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.