Return to Snippet

Revision: 2016
at December 15, 2006 09:04 by assbach


Updated Code
$selsearch =	'
SELECT 
	Uni,Prof,Bearbeiter,Jahr,Semester,ID,Thema,status
FROM 
	Habilitation 
	WHERE 1 ';
	
if ( strlen($_GET["uni"])>0 ) { $selsearch	.= ' AND Uni LIKE "'.$_GET["uni"].'%" '; }
if ( strlen($_GET["jahr"])>0 ) { $selsearch	.= ' AND jahr LIKE "'.$_GET["jahr"].'%" '; }
if ( strlen($_GET["thema"])>0 ) { $selsearch	.= ' AND Thema LIKE "%'.$_GET["thema"].'%" '; }

$selsearch .=	' ORDER BY '.$o.' LIMIT '.$posSelect.','.$perpage;

Revision: 2015
at December 15, 2006 09:02 by assbach


Initial Code
$selsearch	=	'
SELECT 
	Uni,Prof,Bearbeiter,Jahr,Semester,ID,Thema,status
FROM 
	Habilitation 
	WHERE 1 ';
	
if ( strlen($_GET["uni"])>0 ) { $selsearch	.= ' AND Uni LIKE "'.$_GET["uni"].'%" '; }
if ( strlen($_GET["jahr"])>0 ) { $selsearch	.= ' AND jahr LIKE "'.$_GET["jahr"].'%" '; }
if ( strlen($_GET["thema"])>0 ) { $selsearch	.= ' AND Thema LIKE "%'.$_GET["thema"].'%" '; }

$selsearch	.=	' ORDER BY '.$o.' LIMIT '.$posSelect.','.$perpage;

Initial URL

                                

Initial Description
Building a SELECT with conditional WHERE parts, given from form-get parameters.

Initial Title
SELECT with conditional WHERE parts

Initial Tags
mysql, sql, php

Initial Language
PHP