jarv Posted July 26, 2010 Share Posted July 26, 2010 here is my code, I am working with iUI and trying to link the 2 ULs with PHP and query strings, can someone please help? thanks <?php include_once("config.php"); include_once("functions.php"); // Check user logged in already: checkLoggedIn("yes"); //doCSS(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>gopub</title> <link rel="stylesheet" type="text/css" href="stylesheets/style1.css" title="default" /> <meta name="viewport" content="width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.0; user-scalable=0;"/> <link rel="apple-touch-icon" href="../iui/iui/iui-logo-touch-icon.png" /> <style type="text/css" media="screen">@import "../iui/iui/iui.css";</style> <script type="application/x-javascript" src="../iui/iui/iui.js"></script> <meta name="apple-touch-fullscreen" content="YES" /> <script type="text/javascript" src="js/jva.js"></script> <style type="text/css"> body > ul > li { font-size: 14px; } body > ul > li > a { padding-left: 54px; padding-right: 40px; min-height: 34px; } li .digg-count { display: block; position: absolute; margin: 0; left: 6px; top: 7px; text-align: center; font-size: 110%; letter-spacing: -0.07em; color: #93883F; font-weight: bold; text-decoration: none; width: 36px; height: 30px; padding: 7px 0 0 0; background: url(shade-compact.gif) no-repeat; } h2 { margin: 10px; color: slateblue; } p { margin: 10px; } </style> </head> <body> <? $offset = (isset($_GET['start'])) ? (int)$_GET["start"] : 0; $rowsPerPage = (isset($_GET['count'])) ? (int)$_GET["count"] : 10; $query = "SELECT * FROM pubs LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die(mysql_error().'<br>SQL: ' . $query); //looping counties $query1 = "SELECT rsCounty, COUNT(PubID) AS County_Count FROM pubs GROUP BY rsCounty"; $result1 = mysql_query($query1) or die(mysql_error().'<br>SQL: ' . $query1); $County1 = $result1['rsCounty']; $CountyCount = $result1['County_Count']; ?> <div class="toolbar"> <h1 id="pageTitle"></h1> <a id="backButton" class="button" href="#"></a> <a class="button" href="#searchForm">Search</a> </div> <ul title="county" id="county" selected="true"> <?php while ($row = mysql_fetch_assoc($result1)){ $RSCOUNTY1 = $row['rsCounty']; $CountyCount = $row['County_Count']; echo <<<EOF <li><a href="#" class="digg-count">$CountyCount</a></li> <li><a href="#pubs?rsCounty=$RSCOUNTY1">$RSCOUNTY1</a></li> EOF; } echo "</ul>"; // start main page while($row = mysql_fetch_array($result)){ $PUBID = $row['PUBID']; $RSPUBNAME = $row['RSPUBNAME']; $RSADDRESS = $row['RSADDRESS']; $RSPOSTCODE = $row['RSPOSTCODE']; $RSTEL = $row['RSTEL']; $RSTOWN = $row['RSTOWN']; $RSCOUNTY = $row['RSCOUNTY']; // how many rows we have in database // print the link to access each page $self = $_SERVER['PHP_SELF']; $next = "<li><a href=\"all.php?start=" . ($offset + $rowsPerPage) . "&count={$rowsPerPage}\" target=\"_replace\">View More</a></li>"; //div container of header and information echo "<ul title=\"pubs\" id=\"pubs\">"; echo <<<EOF <li><a href="#">$RSPUBNAME</a></li> EOF; if ($_SESSION["RSUSER"] == "admin") { echo "<a href=\"edit.php?PUBID=$PUBID\" class=\"small\">edit this pub</a>"; } } echo $next; echo "</ul>"; ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
jarv Posted July 26, 2010 Author Share Posted July 26, 2010 I am getting the error message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE rsCounty =' at line 1 SQL: SELECT * FROM pubs LIMIT 0, 10 WHERE rsCounty = I did change this line: $query = "SELECT * FROM pubs LIMIT $offset, $rowsPerPage WHERE rsCounty =" .$_GET['rsCounty']; Quote Link to comment Share on other sites More sharing options...
Wolphie Posted July 26, 2010 Share Posted July 26, 2010 $query = "SELECT * FROM pubs LIMIT $offset, $rowsPerPage WHERE rsCounty ='" . $_GET['rsCounty'] . '"; When inserting a string in a MySQL query you must surround the variable/string within single quotes. Quote Link to comment Share on other sites More sharing options...
jarv Posted July 26, 2010 Author Share Posted July 26, 2010 I now get: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in D:\jbiddulph.com\wwwroot\iphone\pubs\pubs.php on line 65 here is my code: $query = "SELECT * FROM pubs LIMIT $offset, $rowsPerPage WHERE rsCounty ='" .$_GET['rsCounty'] "'"; Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 26, 2010 Share Posted July 26, 2010 $query = "SELECT * FROM pubs WHERE rsCounty = '{$_GET['rsCounty']}' LIMIT $offset, $rowsPerPage"; Quote Link to comment Share on other sites More sharing options...
jarv Posted July 26, 2010 Author Share Posted July 26, 2010 that's better thanks but my ULs are still not linking?! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.