Completed

Construisez un site Web

Adjust PHP code:

I am running a Dating website. The current code filter menbesr by:

-gender

-sexual interest

-country and city

-new or older

I want to add age range filter. I need someone to edit the code below. I will add $agemin and $agemax in the current database and i will adjust by myself the form.

Thanks.

// Filter

$filter = $db->query("SELECT * FROM filters WHERE user_id='".$user->id."'");

$num_rows = $filter->num_rows;

if($num_rows >= 1) {

$filter = $filter->fetch_object();

} else {

$filter = new stdClass();

$filter->sexual_preference = 3;

$filter->sexual_orientation = 1;

$filter->country = 'All Countries';

$filter->city = '';

$filter->order_by = 4;

}

// Create / Update Filter

if(isset($_POST['filter'])) {

$sexual_preference = $_POST['sexual_preference'];

$sexual_orientation = $_POST['sexual_orientation'];

$country = $_POST['country'];

$order_by = $_POST['order_by'];

$city = $_POST['city'];

if($num_rows == 0) {

$db->query("INSERT INTO filters (user_id,sexual_preference,country,order_by,city,sexual_orientation) VALUES ('".$user->id."','".$sexual_preference."','".$country."','".$order_by."','".$city."','".$sexual_orientation."')");

header('Location: '.$system->getDomain().'/people');

exit;

} else {

$db->query("UPDATE filters SET sexual_preference='".$sexual_preference."',country='".$country."',order_by='".$order_by."',city='".$city."',sexual_orientation='".$sexual_orientation."' WHERE user_id='".$user->id."'");

header('Location: '.$system->getDomain().'/people');

exit;

}

}

// Format Query

switch ($filter->sexual_preference) {

case 1:

$gender = 'WHERE gender=\'Male\'';

break;

case 2:

$gender = 'WHERE gender=\'Female\'';

break;

case 3:

$gender = 'WHERE gender IS NOT NULL';

break;

default:

$gender = 'WHERE gender IS NOT NULL';

break;

}

switch ($filter->sexual_orientation) {

case 1:

$sexual_orientation = 'AND sexual_interest=\'1\'';

break;

case 2:

$sexual_orientation = 'AND sexual_interest=\'2\'';

break;

case 3:

$sexual_orientation = 'AND sexual_interest=\'3\'';

break;

case 4:

$sexual_orientation = 'AND sexual_interest=\'4\'';

break;

default:

$sexual_orientation = 'AND country LIKE \'%'.$filter->sexual_orientation.'%\'';

break;

}

switch ($filter->country) {

case 'All Countries':

$country = 'AND country IS NOT NULL';

break;

default:

$country = 'AND country LIKE \'%'.$filter->country.'%\'';

break;

}

$city = 'AND city LIKE \'%'.$filter->city.'%\'';

switch ($filter->order_by) {

case 1:

$order = 'ORDER BY id DESC';

break;

case 2:

$order = 'ORDER BY id ASC';

break;

case 3:

$order = 'ORDER BY last_active DESC';

break;

case 4:

$order = 'ORDER BY RAND()';

break;

default:

$order = 'ORDER BY RAND()';

break;

}

if(!isset($_POST['search'])) {

$query = '';

$people = "SELECT * FROM users $gender $sexual_orientation $country $me $city AND id != ".$user->id." $order";

} else {

$query = ucfirst(strtolower($system->secureField($_POST['query'])));

$people = "SELECT * FROM users WHERE full_name LIKE '%".$query."%' AND id != ".$user->id."";

}

Skills: MySQL, PHP

See more: un code, dating website format, web site update, step create web site iis, create footer header web site, create web site automatically iis, create online hyip program web site, book create web site, create client login access web site, create simple web site, create web site table, web site design update data web page

About the Employer:
( 22 reviews ) hongkong, Hong Kong

Project ID: #9847581

Awarded to:

diastark

Hello sir/madam , We have good experience of PHP,JOOMLA,HTML,HTML5,CSS, Ajax,jquesry,JavaScript,Mysql, Graphic Design,Website Design, Android, mobile application,Photoshop, Banner Design ,Flayer mail,Logo Design,wo More

$30 USD in 0 days
(175 Reviews)
6.7

3 freelancers are bidding on average $39 for this job

moonwebtech

Hi, We are a skilled development team and we are working in web development for the last four years we can complete your task in efficient time and cost please fell free to contact us Thanks moonwebtech

$35 USD in 1 day
(211 Reviews)
7.3
Webbleu

Greetings, We have gone through your requirement and would to take this opportunity to work on this project. Can you send a detailed requirement about your project. Please check few work done by us: Feel More

$53 USD in 1 day
(27 Reviews)
4.5