Jump to content

Help with listings script


LukePVB

Recommended Posts

I have a listing script that I put together with dreamweaver that lists ads with page title hyperlinked, company name, phone number, page description, website url and company logo. Right now it lists all the items in my database. Id like to narrow this down by limiting the listings to a specific city and catagory. For example oshawa and basement waterpoofing. Iv got 2 major scripts. I;m not sure which one needs to be modified to narrow down my listing so ill include both.

 

<?php require_once('Connections/BIZread.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

if (PHP_VERSION < 6) {

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

}

 

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

break;

}

return $theValue;

}

}

 

mysql_select_db($database_BIZread, $BIZread);

$query_getListing = "SELECT ads.page_title, ads.company_name, ads.phone_number, ads.address, ads.city, ads.province_state, ads.websiteurl, ads.page_description, ads.image, ads.page_name, ads.catagory FROM ads";

$getListing = mysql_query($query_getListing, $BIZread) or die(mysql_error());

$row_getListing = mysql_fetch_assoc($getListing);

$totalRows_getListing = mysql_num_rows($getListing);

$query_getListing = "SELECT ads.page_title, ads.company_name, ads.phone_number, ads.address, ads.city, ads.province_state, ads.websiteurl, ads.page_description, ads.image, ads.page_name, ads.catagory FROM ads";

$getListing = mysql_query($query_getListing, $BIZread) or die(mysql_error());

$row_getListing = mysql_fetch_assoc($getListing);

$totalRows_getListing = mysql_num_rows($getListing);

?>

 

and

 

<?php do { ?>

<div id="listing">

<div id="pageTitle"> <a href="<?php echo $row_getListing['city']; ?>/<?php echo $row_getListing['catagory']; ?>/<?php echo $row_getListing['page_name']; ?>"><?php echo $row_getListing['page_title']; ?></a></div>

<div id="logo"><img src="images/_r12_c8.jpg" width="114" height="57" /></div>

<div id="companyName"> <?php echo $row_getListing['company_name']; ?></div>

<div id="phoneNumber"> <?php echo $row_getListing['phone_number']; ?></div>

<div id="address"> <?php echo $row_getListing['address']; ?>, <?php echo $row_getListing['city']; ?>, <?php echo $row_getListing['province_state']; ?></div>

<div id="pageDescription"> <?php echo $row_getListing['page_description']; ?></div>

<div id="website"> <?php echo $row_getListing['websiteurl']; ?></div>

</div>

<?php } while ($row_getListing = mysql_fetch_assoc($getListing)); ?>

 

Any help is appreciated.

Link to comment
Share on other sites

It's very basic. Find some mysql tutorials, and learn to read the mysql manual.

Okay thanks for your help so far. I got the code to work somewhat how i want it to. But i dont know how to add a second WHERE function so it narrows down the listing by two catagories not one. the code i got so far is

$query_getListing = "SELECT ads.page_title, ads.company_name, ads.phone_number, ads.address, ads.city, ads.province_state, ads.websiteurl, ads.page_description, ads.image, ads.page_name, ads.catagory FROM ads WHERE City='Oshawa'"
Link to comment
Share on other sites

Use OR.

 

This is not what i'm looking for. This only narrows down the listings by either selecting details that contain a specific city or contain a specific catagory. I'm looking to narrow down the listings to ones that have both the city and the catagory.

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.