php

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
i want same code with switch case.

if($fromdate && $todate)
{
/* Search by Only By Date*/
$sql="SELECT * FROM child_information

INNER JOIN gurdian_information ON gurdian_information.patient_id=child_information.patient_id

        where (child_information.date between '$fromdate' and '$todate') ";
}
elseif($status)
{
$sql="SELECT * FROM child_information

INNER JOIN gurdian_information ON gurdian_information.patient_id=child_information.patient_id

        where child_information.status='$status' ";
}
elseif($name)
{
$sql="SELECT * FROM child_information

INNER JOIN gurdian_information ON gurdian_information.patient_id=child_information.patient_id

        where child_information.name='$name' ";
}


elseif($fathername)
{
$sql="SELECT * FROM child_information

INNER JOIN gurdian_information ON gurdian_information.patient_id=child_information.patient_id

        where child_information.fathername='$fathername' ";
}  

elseif($gender)
{
$sql="SELECT * FROM child_information

INNER JOIN gurdian_information ON gurdian_information.patient_id=child_information.patient_id

        where child_information.gender='$gender' ";
}
Posted by kashanhpgsgmail-com
Asked on July 11, 2016 6:29 pm
0

The switch statement is similar as a series of IF statements on the <b>same expression</b>. Many times, you may want to compare the same expression with many different values, and execute a different piece of code depending on which value it equals to. In that case we use switch statement specifically.

Posted by pHpSupport
Answered On July 11, 2016 7:25 pm