Käynnissä

create recordset

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

Taidot: PHP, SQL

Näytä lisää: value city, substring search, substring in c, substring c, search substring, php script null, php create table, c substring, create table php, sql less than, php script create table, numeric, null, make loop, sql query loop, php connection select, sql retrieve table, query loop, recordset, sql create script, create order, sql select order, loop table, retrieving, will create

Tietoa työnantajasta:
( 37 arvostelua ) Abu Dhabi, United Arab Emirates

Projektin tunnus: #482048

Myönnetty käyttäjälle:

freeskySoft

Ready done this project.

30 $ USD 0 päivässä
(33 arvostelua)
5.7