create recordset

Completado Publicado Aug 3, 2009 Pagado a la entrega
Completado Pagado a la entrega

Hi. I am in need of a php script that will create the following recordset:-

$city = $_SESSION['city'];

IF $_SESSION['city'] != '30' {

SELECT [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], SUBSTRING( [url removed, login to view], 1, 110 ) AS Discription, [url removed, login to view], [url removed, login to view] FROM club_counter LEFT JOIN clubs ON clubs.ClubID=[url removed, login to view]) WHERE club_counter.ClubID=[url removed, login to view] AND clubs.City='$city' AND [url removed, login to view] is not null ORDER BY rand() LIMIT 0,15

I need the above query to retrieve records with the highest numeric value in the [url removed, login to view] column. Also if the result retrieves less than 15 records I need the script to add records that are in the nearest location to the user ($_SESSION['city']). $_SESSION['city'] is a numeric value and cities in the database are ordered to represent near by cities eg. City 7 is close to City 6&8. If the result of the script still doesn't retrieve 15 results the script will then search Cities 5&9 etc. All the time retrieving cities with the highest numeric value for club_counter.counter. I also need to make sure that if there are a total number of records in the database that are less than 15 in all cities then the script will not continue to loop itself in an endless search to make up 15 results.

(result needs to remand as ORDER BY rand().)

} else {

SELECT [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], SUBSTRING( [url removed, login to view], 1, 110 ) AS Discription, [url removed, login to view], [url removed, login to view] FROM club_counter LEFT JOIN clubs ON clubs.ClubID=[url removed, login to view]) WHERE club_counter.ClubID=[url removed, login to view] AND [url removed, login to view] is not null ORDER BY rand() LIMIT 0,15

I need the above query to retrieve records with the highest numeric value in the [url removed, login to view] column, but in all cities. (result needs to remand as ORDER BY rand().)

}

Database is as follows:-

Connection = <?PHP require_once('Connections/[url removed, login to view]'); ?>

Table clubs = ClubID - Numeric

ListingCat - Numeric

ListingSubCat - Numeric

City - Numeric

ClubName - Varchar

Discription - Varchar

DefaultPic - Varchar

Table club_counter = ClubID - Numeric

counter - Numeric

Table Cities = CityID - Numeric (value is in relation to geographical location eg. cities 5,6,7 are near each other. A value '30' is set as $_SESSION['city'] when a users location can not be obtained and is not represented in database other $_SESSION['city] is set as a numeric value represented in this column)

CityName - Varchar

PHP SQL

Nº del proyecto: #482048

Sobre el proyecto

1 propuesta Proyecto remoto Activo Aug 3, 2009

Adjudicado a:

freeskySoft

Ready done this project.

$30 USD en 0 días
(33 comentarios)
5.7