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
https://forums.phpfreaks.com/topic/221036-improving-elegance-of-this-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.