Dynamic Search
Hey there lads, I really hope that ye guys will be able to help as I am findin' meself in quite a pickle. The thing is I am creating a really simple school database which consists of tabels such as teacher, student, room and class.I've been workin' on it for a while and I've gotten must of the functions to work in the backend.
http://mi2oon.monline.dk/3sem/cms/Copy%20of%20search.php
The thing is it sort of looked a little complicated and needed to be expaned. So, I ended up with something that looks like this.
http://mi2oon.monline.dk/3sem/cms/search.php
Pretty simple and neat lookin, huh? Well, at least I think so. I've been woking of the php side of this one so that I actually can check which seach is being made.. and after a little time I came up with this.. and going through all the possible combinations this seems to work well.
However, here is how the php code looks like.
if(isset($_REQUEST['q']) && isset($_REQUEST['class']) && (isset($_REQUEST['student']) || isset($_REQUEST['teacher'])))
{
$name = $_REQUEST['q'];
$student = $_REQUEST['student'];
$teacher = $_REQUEST['teacher'];
$class = $_REQUEST['class'];
$sql_query = "SLECET";
if((strlen($name)>0 || strlen($class)>0)){
if(strlen($name)>0){
echo "Name is set <br />";
}
if(strlen($class)>0){
echo "Class is set <br />";
}
if(isset($teacher) && isset($student))
echo "Teacher and Student is set <br />";
else if(isset($teacher))
echo "Teacher is set <br />";
else
echo "Student is set <br />";
}
else{
echo "ERROR: need more input!";
}
}
else {
echo "ERROR: nothing is set!";
}
So, me question is can I make it so that I can create dynamic sql queries meaning queries according to what actually is being set.
I can provide the list of these different queries if what will help.
Well, as I said I really hope that someone will be able to help me with this as I've been stuck of this for a while. Nevertheless, thank ye so much and I am sorry for not writin' danish.. it's just because I am not very good with it. Though I can explain' a little bit if wanted.
thanks and cheers :)