Page 1 of 1

Newbie Help - merging codes from 2 pages.[Solved]

Posted: Fri Jun 17, 2005 4:17 am
by nexus6
how can i merge this to codes into 1 $query ? is it possible?
I need both of the codes functionality for my admin.php. they both work seprately.

Code: Select all

$orderBy = "";
	     
        if (!empty($_GET['sort'])) {
	     $orderBy	= "ORDER BY " .sqlite_escape_string($_GET['sort']);
         }
       
        $query = "SELECT * FROM beer $orderBy";

this is a nessesary code for my javascript "click to open row" function

and this is my select table from database code...

Code: Select all

if (isset($_GET['tableName'])) {
	  $table = sqlite_escape_string($_GET['tableName']);
	}
       
       $query = "SELECT * FROM $table ORDER BY title";

$result	= sqlite_query($handle, $query) or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));

Posted: Sat Jun 18, 2005 10:50 am
by dreamline
I'm not sure if this is what you meant but here we go:

Code: Select all

$orderBy = "order by";
if (!empty($_GET['sort']))
	{
	$orderBy    = "$orderBy " . sqlite_escape_string($_GET['sort']);
	}
	else
	{
	$orderBy	="$orderBy title";
	}

if (isset($_GET['tableName']))
	{      
	$table = sqlite_escape_string($_GET['tableName']);
	}
	else
	{
	$table='beer';
	}

$query = "SELECT * FROM $table $orderBy";

$result    = sqlite_query($handle, $query) or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));
JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sun Jun 19, 2005 8:09 pm
by nexus6
thank you very much! :) this was exactly what i needed:)

one more thing - how do i post this Solved

Posted: Mon Jun 20, 2005 2:27 am
by dreamline
Just edit your post and add [solved] to the title.. :)