I am setting up a very basic Directory using mysql and php I can get everything working but the look just isnt what I want
I have created a page index.php with the following code in it
Start of Page above tag
[php]
<?php $maxRows_links = $linEntries; $pageNum_links = 0; if (isset($_GET['pageNum_links'])) { $pageNum_links = $_GET['pageNum_links']; } $startRow_links = $pageNum_links * $maxRows_links; mysql_select_db($database_dbConnect, $dbConnect); $query_links = "SELECT * FROM linkListings"; $query_limit_links = sprintf("%s LIMIT %d, %d", $query_links, $startRow_links, $maxRows_links); $links = mysql_query($query_limit_links, $dbConnect) or die(mysql_error()); $row_links = mysql_fetch_assoc($links); if (isset($_GET['totalRows_links'])) { $totalRows_links = $_GET['totalRows_links']; } else { $all_links = mysql_query($query_links); $totalRows_links = mysql_num_rows($all_links); } $totalPages_links = ceil($totalRows_links/$maxRows_links)-1; $queryString_links = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_links") == false && stristr($param, "totalRows_links") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_links = "&" . htmlentities(implode("&", $newParams)); } } $queryString_links = sprintf("&totalRows_links=%d%s", $totalRows_links, $queryString_links); ?>[/php]
in the body section I have the following
[php]
Filter Results By | >All Listings <?php do { ?> ><?php echo $row_links['Catagory']?> <?php } while ($row_links = mysql_fetch_assoc($links)); $rows = mysql_num_rows($links); if($rows > 0) { mysql_data_seek($links, 0); $row_links = mysql_fetch_assoc($links); } ?> |
<?php echo $row_links['title']; ?> |
<?php echo $row_links['desc']; ?> |
When a visitor makes a selection from the list they go to indexFilter.php with the following code in
Above the tag
[php]
<?php $maxRows_links = $linEntries; $pageNum_links = 0; if (isset($_GET['pageNum_links'])) { $pageNum_links = $_GET['pageNum_links']; } $startRow_links = $pageNum_links * $maxRows_links; mysql_select_db($database_dbConnect, $dbConnect); $query_links = "SELECT * FROM linkListings WHERE linkListings.Catagory = '$listCat' "; $query_limit_links = sprintf("%s LIMIT %d, %d", $query_links, $startRow_links, $maxRows_links); $links = mysql_query($query_limit_links, $dbConnect) or die(mysql_error()); $row_links = mysql_fetch_assoc($links); if (isset($_GET['totalRows_links'])) { $totalRows_links = $_GET['totalRows_links']; } else { $all_links = mysql_query($query_links); $totalRows_links = mysql_num_rows($all_links); } $totalPages_links = ceil($totalRows_links/$maxRows_links)-1; $queryString_links = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_links") == false && stristr($param, "totalRows_links") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_links = "&" . htmlentities(implode("&", $newParams)); } } $queryString_links = sprintf("&totalRows_links=%d%s", $totalRows_links, $queryString_links); ?>[/php]
in the section
[php]
Filter Results By | >Shopping >Travel >Sport <?php do { ?> ><?php echo $row_links['Catagory']?> <?php } while ($row_links = mysql_fetch_assoc($links)); $rows = mysql_num_rows($links); if($rows > 0) { mysql_data_seek($links, 0); $row_links = mysql_fetch_assoc($links); } ?> |
<?php echo $row_links['title']; ?> |
<?php echo $row_links['desc']; ?> |
The trouble is when the pages are loaded nothing is selected in the menu.
When a selection is made and the page is redirected to indexFilter.php nothing at all shown until you make a selection.
When the page reloads the list box is empty but the listing are there.
What I want is for the selection to remain visible in the list box when the page reloads.
Is this possible