Ive come across part of a code which carries out a search. I dont understand what exactly is going on?
My question is, the code i have pasted below, is that code generated by a program (and if so what the program is called and used with?) or can you also write a search like this below thru learning from books, websites etc.
$sql = "SELECT DISTINCT personal.p_id, personal.lname, personal.fname, personal.email from personal, skill, educ WHERE personal.j_num = '$j_num'";
if(isset($skills) && $skills!= "" && isset($opr) && $opr!= "" && isset($years) && $years!= "" )
{
$sql .= " AND personal.p_id = skill.p_id AND (";
$keywords = split(" ", $skills);
for ($x=0; $x<sizeof($keywords); $x++)
{
trim($keywords[$x]);
if($x != 0)
{
$query .= " AND";
}
$sql .= " (skill.skill LIKE '%" . $keywords[$x] ."%' AND skill.exper " . $opr . $years . " )";
}
$sql .= ")";
}
if(!empty($degree) && !empty($subject))
{
$sql .= " AND personal.p_id = educ.p_id AND educ.degree = '$degree' AND educ.subject = '$subject'";
}
$query = mysql_query($sql) or exit ("Error in query: $sql. " . mysql_error());
$num_rows = mysql_num_rows($query);
?>
The same q's above for this as well. This piece of code is used to display errors once an application has been filled out
for ($x=0; $x<count($uni); $x++)
{
if(strlen($uni[$x]))
{
if(!strlen($uni[$x]))
{
$errorList[$list] = "There are errors is your education section. " . ($x+1);
$list++;
}
}
}
for ($x=0; $x<count($emp); $x++)
{
if (strlen($emp[$x]) && strlen($resp[$x]) && is_numeric($start_year[$x]) && is_numeric($end_year[$x]))
{
if(!is_numeric($start_year[$x]) || !is_numeric($end_year[$x]) || !strlen($resp[$x]) || !strlen($emp[$x]))
{
$errorList[$list] = "There are errors in your previous employment details. " . ($x+1);
$list++;
}
}
}
for ($x=0; $x<count($skill); $x++)
{
if (strlen($skill[$x]) && strlen($exper[$x]))
{
if(!is_numeric($exper[$x]) || !strlen($skill[$x]))
{
$errorList[$list] = "There are errors in the skills section " . ($x+1);
$list++;
}
}
}
Thanks