带有标签的php简单搜索框

I am trying to make a simple search box beside group of tabs, the search box is used only to search for phone types, I made this code and every thing work except the search box.it gives me this error: Notice: Undefined index: search

<form action="" method="post" name="form" > 
<body>  
<script>
$(function() {
$( "#xx" ).tabs();
});
</script>


<div id="xx" >
<ul>
<li><a href="#all">all phones</a></li>
<li><a href="#small">small</a></li>
<li><a href="#large">large</a></li>
<li><a href="#search">search:<input type="text" name="search">
</a></li>
</ul>   

<?php
include 'db.php'; 
?>

<div id="all">
<?php 
$res = mysql_query("SELECT * FROM table1");
while($row = mysql_fetch_array($res))
{         
echo 'phone name'.$row[2];
echo 'phone type'.$row[3];
echo 'phone sise'.$row[4];
}
?> 
</div>


<div id="small">   
<?php 
$res2 = mysql_query("SELECT * FROM table1 WHERE phonesize = 'small' ");
while($row = mysql_fetch_array($res2))
{         
echo 'phone name'.$row[2];
echo 'phone type'.$row[3];
echo 'phone sise'.$row[4];
}
?> 
</div>

<div id="large">   
<?php 
$res3 = mysql_query("SELECT * FROM table1 WHERE phonesize = 'large' ");
while($row = mysql_fetch_array($res3))
{         
echo 'phone name'.$row[2];
echo 'phone type'.$row[3];
echo 'phone sise'.$row[4];
}
?> 
</div>


<div id="large">   

 <?php     
$search = $_POST['search'];   
$res4 = mysql_query("SELECT * FROM table1 WHERE phonetype = '$search'");
while($row = mysql_fetch_array($res4))
{         
echo 'phone name'.$row[2];
echo 'phone type'.$row[3];
echo 'phone sise'.$row[4];
}
?> 
</div> 


</form>

The first time the form loads, $_POST['search'] doesn't exist, that's what's causing the notice. It isn't until you actually post to the form that that variable exists. You should check for the existence of that variable before executing your code that you want to execute after the user submits the form, this like:

if( isset( $_POST )) {
    // The form was posted.
    // Write your code here to execute once the user posts the form.
]

good......... The first time the form loads, $_POST['search'] doesn't exist, that's what's causing the notice. It isn't until you actually post to the form that that variable exists. You should check for the existence of that variable before executing your code that you want to execute after the user submits the form, this like: