multiple div show and hide through database using dropdown list

$con = mysql_connect(“localhost”,”root”,””) or die(“mysql conn. error”);
mysql_select_db(‘databasename’) or die(“mysql conn. error”); // database connection

if(isset($_GET[‘Name’]))  //get  value through URL
{
$name = $_GET[‘Name’];
$query = “select * from cad where Name = ‘”.$name.”‘”;
$qu = mysql_query($query, $con);
while($res= mysql_fetch_array($qu))
{
if($res[‘ptype’] == ‘Half Yearly Payment’)
{

$Name = $res[“Name”];
$ptype = $res[“ptype”];
}
else if($res[‘ptype’] == ‘Monthly Payment’)
{

$Name = $res[“Name”];
$ptype = $res[“ptype”];

}
else if($res[‘ptype’]==’Quarterly Payment’)
{

$Name = $res[“Name”];
$ptype = $res[“ptype”];
}
else
{
$Name = $res[“Name”];

$ptype = $res[“ptype”];
}
}
}

// html code

<select class=”drop” id=”payment” name=”ptype” >
<option  id=”S_0″ value=”Monthly Payment”>Monthly Payment</option>
<option  id=”S_1″ value=”Quarterly Payment”>Quarterly Payment</option>
<option  id=”S_2″ value=”Half Yearly Payment”>Half Yearly Payment</option>
<option  id=”S_3″ value=”Yearly Payment”>Yearly Payment</option>
</select>

// multiple div show and hide php code

if($res[‘ptype’]== ‘Monthly Payment’)

{

  echo  $Name;    

   echo $ptype;

}

if($res[‘ptype’]== ‘Quarterly Payment’)

{

  echo  $Name;    

   echo $ptype;

}

if($res[‘ptype’]== ‘Half Yearly Payment’)

{

  echo  $Name;    

   echo $ptype;

}

if($res[‘ptype’]== ‘Yearly Payment’)

{

  echo  $Name;    

   echo $ptype;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s