Jump to content

Improving elegance of this code?!


Vivid Lust

Recommended Posts

Hi all!

 

I am currently reprogramming my site with objects etc, making it better. I have some code below and am not sure upon how to make it better. loops, cases, classes, functions etc not sure what to do, currently looks like a jumble, here it is, am looking comments on how I can improve how it looks and maybe split it up more or someting, not sure:

#####  FIND OUT SQL TO SHOW RESULTS ##### 
// country results sql
if( $_GET['country'] != "" ){

	$keyword = str_ireplace("_"," ",$_GET['country']);
	$keyword = langCountryNum($keyword,"COUNTRY",138);

	$sql = 'SELECT * FROM exchange WHERE `location` = "'.$keyword.'" ORDER BY FROM_UNIXTIME(lastOnline) DESC';
	$urlText = "/xxxxx/".( in_array($lang,$_ENV['supportedLanguages']) ? $lang."/" : $nothing).HEADlanguage_exchange."/country/".HEADbefore_lang.constant("COUNTRY" .$keyword).HEADafter_lang;

//language results sql		
}elseif( $_GET['language'] != "" ){
	$keyword = str_ireplace("_"," ",$_GET['language']);
	$keyword = langCountryNum($keyword,"Lang",130);
	$sql = 'SELECT * FROM exchange WHERE `option` = "'.$keyword.'" ORDER BY FROM_UNIXTIME(lastOnline) DESC';
	$urlText = "/xxxx/".( in_array($lang,$_ENV['supportedLanguages']) ? $lang."/" : $nothing).HEADlanguage_exchange."/language/".HEADbefore_lang.constant("Lang" .$keyword).HEADafter_lang;
// all members results sql 
}else{
  		$sql = "SELECT * FROM exchange ORDER BY id DESC";
  		$urlText = ( in_array($lang,$_ENV['supportedLanguages']) ? $lang."/" : $nothing).HEADall_penpals;
	}
#####  END FIND OUT SQL TO SHOW RESULTS ##### 

 

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.