List Menu Help

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 do { ?>
<?php echo $row_links['title']; ?>
<?php echo $row_links['desc']; ?>
<?php } while ($row_links = mysql_fetch_assoc($links)); ?>
">First ">Previous ">Next ">Last
[/php]

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 do { ?>
<?php echo $row_links['title']; ?>
<?php echo $row_links['desc']; ?>
<?php } while ($row_links = mysql_fetch_assoc($links)); ?>
">First ">Previous ">Next ">Last
[/php]

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

hi,

lots if information. i’m sorry i can’t work myself thru all of ur code.

4 things i found after i had a quick lock at it (may be they work, but i haven’t tested ur code):

  1. [php]$query_links = "SELECT * FROM linkListings WHERE linkListings.Catagory = ‘$listCat’ ";[/php]
    if $listCat is not set it will be “linkListings.Catagory = ‘’”
    try:
    [php]$query_links = “SELECT * FROM linkListings”;
    if(isset($listCat))$query_links .= "WHERE linkListings.Catagory = ‘$listCat’ ";[/php]

  2. u are using while ($row_links = mysql_fetch_assoc($links)) twice.
    there sould be no more data in the second loop.
    try to catch it in an array first:
    [php]while ($row_links = mysql_fetch_assoc($links)) $all_rows_links[]=$row_links;[/php]
    and use foreach($all_rows_links as $row_links) instead of while ($row_links = mysql_fetch_assoc($links)

  3. [php]if(!(strcmp($row_links[‘Catagory’], $row_links[‘Catagory’])))[/php]
    will always return true. try:
    [php]if($row_links[‘Catagory’]==$listCat))[/php]

  4. May it’s just the forum hiding them. But ur <?php ?> tags arn’t matching in the posted code. and some are missing. (u would see the php code in the HTML-source, if so.)

hope at least one of them solves ur problem, or gives u point to start from.

Sponsor our Newsletter | Privacy Policy | Terms of Service