Jump to content

Need help retrieving results from certain table


Jdog

Recommended Posts


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

&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 } ?>

 

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

&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 } ?>
Edited by Jdog
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.