As thread title says, currently using this code to pull in listings from the "listings" table in the database <?PHP if ($_POST[limit] != $nil) $_SESSION['limit'] = $_POST['limit']; if ($_SESSION[limit] == $nil) $_SESSION['limit'] = 20; //--------------------------------------- ?> <?PHP include "bit_centerbar.php"; ?> <?php //------------------------- if (empty($rowxxx['SORT'])) $rowxxx['SORT'] = 'TITLE ASC'; else { if ($rowxxx['SORT'] == Alphabetically) $rowxxx['SORT'] = 'TITLE ASC'; if ($rowxxx['SORT'] == 'Date Added') $rowxxx['SORT'] = 'YA DESC, MA DESC, DA DESC, TITLE DESC'; if ($rowxxx['SORT'] == 'Date Updated') $rowxxx['SORT'] = 'YU DESC, MU DESC, DU DESC, TITLE ASC'; } if (empty($_GET[sortby])) $sort = $rowxxx['SORT']; $_GET[sortby] = "$sort"; $table = "LISTINGS"; $string = "WHERE STATUS = 'Active' AND CATEGORY LIKE '%-$_GET[category]-%'"; if (empty($_GET[category])) $string = "WHERE STATUS = 'Active'"; if ($_GET[category] == '') $string = "WHERE ID != ''"; $swap = "&page=$_GET[page]&category=$_GET[category]"; //------------------------------------------------------------------------------------------- $query1 = @mysql_query ("SELECT * FROM $table INNER JOIN PACKAGES ON LISTINGS.PACKAGE = PACKAGES.ID $string $adv_search ORDER BY PACKAGES.RANK ASC, $_GET[sortby]"); //$query1 = @mysql_query ("SELECT * FROM $table $string $adv_search ORDER BY $_GET[sortby]"); $numrows= @mysql_num_rows ($query1); if (!isset ($_GET['show'])) { $display = 1; } else { $display = $_GET['show']; } $start = (($display * $_SESSION['limit']) - $_SESSION['limit']); $query2 = @mysql_query ("SELECT *, LISTINGS.ID AS LID FROM $table INNER JOIN PACKAGES ON LISTINGS.PACKAGE = PACKAGES.ID $string $adv_search ORDER BY PACKAGES.RANK ASC, $_GET[sortby] LIMIT $start,$_SESSION[limit]"); //$query2 = @mysql_query ("SELECT * FROM $table $string $adv_search ORDER BY $_GET[sortby] LIMIT $start,$_SESSION[limit]"); while ($row = @mysql_fetch_array ($query2)) { include "browse_display.php"; } //------------------------------------------------------------------------------------------- ?> <?php if ($numrows == '0') { ?> <div class="tdbox" style="width: 100%;"></div> <?php if (empty($_GET[category])) include 'bit_centerbar.php'; ?> <? echo $browse_no; ?> <?PHP } else { ?> <form action="?show=1&page=browse&category=<?php echo $_GET[category]; ?>&mode=<?php echo $_GET[mode]; ?>" method="post" name="form" id="form"> <div class="pagi" style="margin-top: 15px;"> <input type="submit" name="Submit" value="<? echo $browse_show; ?>" /> <select name="limit"> <option selected> <?php echo $_SESSION['limit']; ?> </option> <option>1</option> <option>5</option> <option>10</option> <option>20</option> <option>30</option> <option>50</option> <option>100</option> </select> <? echo $browse_lists; ?> <?php include "pagination_bot.php"; ?> </div> </form> <?PHP } ?> Code (markup): But now I am trying to find a way to display the results from particular states, i.e. Victoria, Queensland(this is from Australia). I am trying the following code, but currently getting the "no listings here, check back soon" message with no errors. I'm very new to PHP so not sure if I need to tweak the code to pull the results from the "LISTINGS" table, or the "LOCATIONS" <?PHP if ($_POST[limit] != $nil) $_SESSION['limit'] = $_POST['limit']; if ($_SESSION[limit] == $nil) $_SESSION['limit'] = 20; //--------------------------------------- ?> <?PHP include "bit_centerbar.php"; ?> <?php //------------------------- if (empty($rowxxx['SORT'])) $rowxxx['SORT'] = 'TITLE ASC'; else { if ($rowxxx['SORT'] == Alphabetically) $rowxxx['SORT'] = 'TITLE ASC'; if ($rowxxx['SORT'] == 'Date Added') $rowxxx['SORT'] = 'YA DESC, MA DESC, DA DESC, TITLE DESC'; if ($rowxxx['SORT'] == 'Date Updated') $rowxxx['SORT'] = 'YU DESC, MU DESC, DU DESC, TITLE ASC'; } if (empty($_GET[sortby])) $sort = $rowxxx['SORT']; $_GET[sortby] = "$sort"; $table = "LISTINGS"; $string = "WHERE STATUS = 'Active' AND CATEGORY LIKE '%-$_GET[STATE]-%'"; if (empty($_GET[category])) $string = "WHERE STATUS = 'Active'"; if ($_GET[category] == '') $string = "WHERE ID != 'Queensland'"; $swap = "&page=$_GET[page]&state=$_GET[state]"; //------------------------------------------------------------------------------------------- $query1 = @mysql_query ("SELECT * FROM $table INNER JOIN PACKAGES ON LISTINGS.PACKAGE = PACKAGES.ID $string $adv_search ORDER BY PACKAGES.RANK ASC, $_GET[sortby]"); //$query1 = @mysql_query ("SELECT * FROM $table $string $adv_search ORDER BY $_GET[sortby]"); $numrows= @mysql_num_rows ($query1); if (!isset ($_GET['show'])) { $display = 1; } else { $display = $_GET['show']; } $start = (($display * $_SESSION['limit']) - $_SESSION['limit']); $query2 = @mysql_query ("SELECT *, LISTINGS.ID AS LID FROM $table INNER JOIN PACKAGES ON LISTINGS.PACKAGE = PACKAGES.ID $string $adv_search ORDER BY PACKAGES.RANK ASC, $_GET[sortby] LIMIT $start,$_SESSION[limit]"); //$query2 = @mysql_query ("SELECT * FROM $table $string $adv_search ORDER BY $_GET[sortby] LIMIT $start,$_SESSION[limit]"); while ($row = @mysql_fetch_array ($query2)) { include "bwose_display.php"; } //------------------------------------------------------------------------------------------- ?> <?php if ($numrows == '0') { ?> <div class="tdbox" style="width: 100%;"></div> <?php if (empty($_GET[category])) include 'bit_centerbar.php'; ?> <? echo $browse_no; ?> <?PHP } else { ?> <form action="" method="post" name="form" id="form"> <div class="pagi" style="margin-top: 15px;"> <input type="submit" name="Submit" value="<? echo $browse_show; ?>" /> <select name="limit"> <option selected> <?php echo $_SESSION['limit']; ?> </option> <option>1</option> <option>5</option> <option>10</option> <option>20</option> <option>30</option> <option>50</option> <option>100</option> </select> <? echo $browse_lists; ?> <?php include "pagination_bot.php"; ?> </div> </form> <?PHP } ?> Code (markup):
Are your states in the GET formatted like -Victoria- That's what your WHERE clause claims. If it's just Victoria lose the hyphens in the LIKE.
Like this?? $table = "LISTINGS";$string = "WHERE STATUS = 'Active' AND CATEGORY LIKE '%$_GET[STATE]%'"; if (empty($_GET[category])) $string = "WHERE STATUS = 'Active'"; if ($_GET[category] == '') $string = "WHERE ID != 'Victoria'"; $swap = "&page=$_GET[page]&state=$_GET[state]"; Code (markup): I tried with the URL /index.php?page=victoria&category=2& And it just lists all of the listings from category 2, it doesn't only display the Victoria ones. I'm very stumped.