scaleautostyle Posted July 7, 2010 Share Posted July 7, 2010 Hi everyone... I try to adapt the previous coding to met my needs. but looklike it's not easy than was I think. I receive this message when I it the submit button.... Notice: Undefined index: manufacturer_reel in ......search-db.php on line 18 select * from student whe this is my code <?php include_once("db_connection.php"); ////////////////////////////// ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>(Type a title for your page here)</title> </head> <body > <?php if (isset($_POST['todo']) && $_POST['todo'] == "search") { $todo=$_POST['todo']; $manufacturer_reel=$_POST['manufacturer_reel']; $query="select * from kit where "; ////////// Including manufacturer_reel field search //// if(strlen($manufacturer_reel) > 0 ){ $query.= " manufacturer_reel='$manufacturer_reel' and "; } //// End of class field search /////////// $query=substr($query,0,(strLen($query)-4)); echo $query; echo "<br><br>"; $nt=mysql_query($query); echo mysql_error(); // End if form submitted }else{ echo "<form method=post action=''><input type=hidden name=todo value=search>"; $q=mysql_query("SELECT DISTINCT manufacturer_reel FROM kit ORDER BY manufacturer_reel"); echo '<select name=manufacturer_reel="manufacturer_reel"><option>Reel manufacturer</option>'; while($row = mysql_fetch_array($q)) { $thing = $row['manufacturer_reel']; echo '<option>'.$thing.'</option>'; } echo "</select>"; echo " <br><input type=submit value=Search name='name' action='search.php?go'> </form> "; } ?> </body> </html> and this is my search-keyword.php file that supposed to return the appropriate data. thanks in advance sebastien <?php include_once("db_connection.php"); ////////////////////////////// ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>(Type a title for your page here)</title> </head> <body > <?php if (isset($_POST['todo']) && $_POST['todo'] == "search") { $todo=$_POST['todo']; $manufacturer_reel=$_POST['manufacturer_reel']; //-query the database table for the post field $sql="SELECT kit_id, kit_number, kit_name, description, manufacturer_kit, manufacturer_reel, scale, engine_detail, year_prod_kit, year_prod_reel, image_id, image_id1, image_id2 FROM kit WHERE manufacturer_reel LIKE '%" . $manufacturer_reel ."%'"; //-run the query against the mysql query function $result=mysql_query($sql); //-make the header of the table echo " <table align=center width=\"1255\" border=\"\">\n"; echo " <tr>\n"; echo" <td nowrap align=center width='95'> kit manufacturer \n"; echo" <td nowrap align=center width='55'> scale \n"; echo" <td nowrap align=center width='90'> kit number \n"; echo" <td nowrap align=center width='290'> kit name \n"; echo" <td nowrap align=center width='400'> description \n"; echo" <td nowrap align=center width='95'> vehicule manufacturer \n"; echo" <td nowrap align=center width='75'> year of reel production of car \n"; echo" <td nowrap align=center width='75'> complete engine detail\n"; echo" <td nowrap align=center width='75'> Select Picture to get bigger\n"; echo" <td nowrap align=center width='75'> instruction sheet\n"; echo" <td nowrap align=center width='50'> box contain\n"; echo " <tr>\n"; //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $description =$row['description']; $manufacturer_kit=$row['manufacturer_kit']; $scale=$row['scale']; $manufacturer_reel=$row['manufacturer_reel']; $kit_id=$row['kit_id']; $kit_number=$row['kit_number']; $kit_name=$row['kit_name']; $engine_detail=$row['engine_detail']; $year_prod_reel=$row['year_prod_reel']; $image_id=$row['image_id']; $image_id1=$row['image_id1']; $image_id2=$row['image_id2']; //-create table of item during he while loop echo " <table align=center width=\"1255\" border=\"\">\n"; echo" <td nowrap align=center width='95'> $manufacturer_kit \n"; echo" <td nowrap align=center width='95'> $scale \n"; echo" <td nowrap align=center width='95'> $manufacturer_reel \n"; echo" <td nowrap align=center width='90'> $kit_number \n"; echo" <td nowrap align=center width='290'> $kit_name \n"; echo" <td nowrap width='400'> $description \n"; echo" <td nowrap align=center width='75'> $year_prod_reel \n"; echo" <td nowrap align=center width='75'> $engine_detail \n"; echo" <td nowrap width='75'> <a href=".$image_id."> <img src='".$image_id."' width='75' height='50' border='0'/>"; echo" <td nowrap width='75'> <a href= ".$image_id1."> <img src= 'http://www.scale24-25.com/images/PDF_logo.gif' width='50' height='50' border='0'/>"; echo" <td nowrap width='50'> <a href=".$image_id2."> <img src='http://www.scale24-25.com/images/PDF_logo.gif' width='50' height='50' border='0'/>"; echo " </tr>\n"; echo " </table>\n"; echo " </tr>\n"; echo " </table>\n"; } } else{ echo "<p>Please enter a search query</p>"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/ Share on other sites More sharing options...
kenrbnsn Posted July 7, 2010 Share Posted July 7, 2010 You are generating improper HTML with this <?php echo '<select name=manufacturer_reel="manufacturer_reel"><option>Reel manufacturer</option>'; ?> Use <?php echo '<select name="manufacturer_reel><option>Reel manufacturer</option>'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082609 Share on other sites More sharing options...
scaleautostyle Posted July 7, 2010 Author Share Posted July 7, 2010 thanks kenrbnsn but are you refering to the live in this code??? <?php // End if form submitted}else{echo "<form method=post action=''><input type=hidden name=todo value=search>";$q=mysql_query("SELECT DISTINCT manufacturer_reel FROM kit ORDER BY manufacturer_reel");echo '<select name=manufacturer_reel="manufacturer_reel"><option>Reel manufacturer</option>';while($row = mysql_fetch_array($q)) {$thing = $row['manufacturer_reel'];echo '<option>'.$thing.'</option>';?> in the case of an afirnative answer you code doen't show my dropdown instead of mine where it show the dropdown. I get the message when I hit the submit button so I think the error is on my searh=keyword file no ?? I know the message says Notice: Undefined index: manufacturer_reel in ......search-db.php on line 18 select * from student whe but ..... yours sebastien Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082620 Share on other sites More sharing options...
kenrbnsn Posted July 7, 2010 Share Posted July 7, 2010 Sorry, forgot a closing quote: <?php echo '<select name="manufacturer_reel"><option>Reel manufacturer</option>'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082624 Share on other sites More sharing options...
scaleautostyle Posted July 7, 2010 Author Share Posted July 7, 2010 sorry I don't why my code doesn't want to show in the last post there is it.. <?php // End if form submitted }else{ echo "<form method=post action=''><input type=hidden name=todo value=search>"; $q=mysql_query("SELECT DISTINCT manufacturer_reel FROM kit ORDER BY manufacturer_reel"); echo '<select name=manufacturer_reel="manufacturer_reel"><option>Reel manufacturer</option>'; while($row = mysql_fetch_array($q)) { ?> Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082630 Share on other sites More sharing options...
scaleautostyle Posted July 7, 2010 Author Share Posted July 7, 2010 thanks kenrbnsn your new code work... the dropdown is theyre. but now when I select a manufacturer anyone... here I took honda I got this result select * from kit where manufacturer_reel='honda' ??? where did they came from in the search-keyword.php file ?? it's realy not that I want. I see some error in my original work and change it so find below my 2 update file The FORM <?php include_once("db_connection.php"); ////////////////////////////// ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>(Type a title for your page here)</title> </head> <body > <?php if (isset($_POST['todo']) && $_POST['todo'] == "search") { $todo=$_POST['todo']; $manufacturer_reel=$_POST['manufacturer_reel']; $query="select * from kit where "; ////////// Including manufacturer_reel field search //// if(strlen($manufacturer_reel) > 0 ){ $query.= " manufacturer_reel='$manufacturer_reel' and "; } //// End of class field search /////////// $query=substr($query,0,(strLen($query)-4)); echo $query; echo "<br><br>"; $nt=mysql_query($query); echo mysql_error(); // End if form submitted }else{ echo "<form method=post action=''><input type=hidden name=todo value=search>"; $q=mysql_query("SELECT DISTINCT manufacturer_reel FROM kit ORDER BY manufacturer_reel"); echo '<select name="manufacturer_reel"><option>Reel manufacturer</option>'; while($row = mysql_fetch_array($q)) { $thing = $row['manufacturer_reel']; echo '<option>'.$thing.'</option>'; } echo "</select>"; echo " <br><input type=submit value=Search name='name' action='search-keyword.php?go' > </form> "; } ?> and the SEARCH-keyword.php where it supposed to return the info. <?php include_once("db_connection.php"); ////////////////////////////// ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>(Type a title for your page here)</title> </head> <body > <?php if (isset($_POST['todo']) && $_POST['todo'] == "search") { $todo=$_POST['todo']; $name=$_POST['name']; //-query the database table for the post field $sql="SELECT kit_id, kit_number, kit_name, description, manufacturer_kit, manufacturer_reel, scale, engine_detail, year_prod_kit, year_prod_reel, image_id, image_id1, image_id2 FROM kit WHERE manufacturer_reel LIKE '%" . $name ."%'"; //-run the query against the mysql query function $result=mysql_query($sql); //-make the header of the table echo " <table align=center width=\"1255\" border=\"\">\n"; echo " <tr>\n"; echo" <td nowrap align=center width='95'> kit manufacturer \n"; echo" <td nowrap align=center width='55'> scale \n"; echo" <td nowrap align=center width='90'> kit number \n"; echo" <td nowrap align=center width='290'> kit name \n"; echo" <td nowrap align=center width='400'> description \n"; echo" <td nowrap align=center width='95'> vehicule manufacturer \n"; echo" <td nowrap align=center width='75'> year of reel production of car \n"; echo" <td nowrap align=center width='75'> complete engine detail\n"; echo" <td nowrap align=center width='75'> Select Picture to get bigger\n"; echo" <td nowrap align=center width='75'> instruction sheet\n"; echo" <td nowrap align=center width='50'> box contain\n"; echo " <tr>\n"; //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $description =$row['description']; $manufacturer_kit=$row['manufacturer_kit']; $scale=$row['scale']; $manufacturer_reel=$row['manufacturer_reel']; $kit_id=$row['kit_id']; $kit_number=$row['kit_number']; $kit_name=$row['kit_name']; $engine_detail=$row['engine_detail']; $year_prod_reel=$row['year_prod_reel']; $image_id=$row['image_id']; $image_id1=$row['image_id1']; $image_id2=$row['image_id2']; //-create table of item during he while loop echo " <table align=center width=\"1255\" border=\"\">\n"; echo" <td nowrap align=center width='95'> $manufacturer_kit \n"; echo" <td nowrap align=center width='95'> $scale \n"; echo" <td nowrap align=center width='95'> $manufacturer_reel \n"; echo" <td nowrap align=center width='90'> $kit_number \n"; echo" <td nowrap align=center width='290'> $kit_name \n"; echo" <td nowrap width='400'> $description \n"; echo" <td nowrap align=center width='75'> $year_prod_reel \n"; echo" <td nowrap align=center width='75'> $engine_detail \n"; echo" <td nowrap width='75'> <a href=".$image_id."> <img src='".$image_id."' width='75' height='50' border='0'/>"; echo" <td nowrap width='75'> <a href= ".$image_id1."> <img src= 'http://www.scale24-25.com/images/PDF_logo.gif' width='50' height='50' border='0'/>"; echo" <td nowrap width='50'> <a href=".$image_id2."> <img src='http://www.scale24-25.com/images/PDF_logo.gif' width='50' height='50' border='0'/>"; echo " </tr>\n"; echo " </table>\n"; echo " </tr>\n"; echo " </table>\n"; } } else{ echo "<p>Please enter a search query</p>"; } } } ?> yours sebastien Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082639 Share on other sites More sharing options...
kenrbnsn Posted July 7, 2010 Share Posted July 7, 2010 The "action" attribute is meaningless in a "<input>" tag. When you submit a form it goes to the script in the "action" attribute in the "<form>" tag. In your case that is the empty string, which says submit the data to the original script. If you want it to go somewhere else, put the script name there. Ken Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082644 Share on other sites More sharing options...
scaleautostyle Posted July 7, 2010 Author Share Posted July 7, 2010 ok but at the end of my form where my submit button is I say the action where to go <?php // End if form submitted }else{echo "<form method=post action=''><input type=hidden name=todo value=search>";$q=mysql_query("SELECT DISTINCT manufacturer_reel FROM kit ORDER BY manufacturer_reel");echo '<select name="manufacturer_reel"><option>Reel manufacturer</option>';while($row = mysql_fetch_array($q)) {$thing = $row['manufacturer_reel'];echo '<option>'.$thing.'</option>';}echo "</select>"; echo "<br><input type=submit value=Search name='name' action='search-keyword.php?go' ></form>";} ?> where other else I have to put the info?? yours sebastien Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082650 Share on other sites More sharing options...
kenrbnsn Posted July 7, 2010 Share Posted July 7, 2010 That doesn't work. The action MUST be in the <form> tag if you're not using Javascript to modify where the form is submitted. Ken Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082655 Share on other sites More sharing options...
scaleautostyle Posted July 7, 2010 Author Share Posted July 7, 2010 HA!!! I just see it thanks now I redo and it start something. it echo my table header but doesn't run the sql query to display something. these code was working number one when I do it with a texte search field. now why it doesn't work in this one.???? see the code in the previous post... search-kewyword.php thaks sebastien Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082682 Share on other sites More sharing options...
kenrbnsn Posted July 7, 2010 Share Posted July 7, 2010 You are searching on the value in $_POST['name'], but your form is passing $_POST['manufacturer_reel'] Change: <?php $name=$_POST['name']; //-query the database table for the post field $sql="SELECT kit_id, kit_number, kit_name, description, manufacturer_kit, manufacturer_reel, scale, engine_detail, year_prod_kit, year_prod_reel, image_id, image_id1, image_id2 FROM kit WHERE manufacturer_reel LIKE '%" . $name ."%'"; ?> to <?php $manufacturer_reel=$_POST['manufacturer_reel']; //-query the database table for the post field $sql="SELECT kit_id, kit_number, kit_name, description, manufacturer_kit, manufacturer_reel, scale, engine_detail, year_prod_kit, year_prod_reel, image_id, image_id1, image_id2 FROM kit WHERE manufacturer_reel LIKE '%" . $manufacturer_reel."%'"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082687 Share on other sites More sharing options...
scaleautostyle Posted July 7, 2010 Author Share Posted July 7, 2010 thank you VERY MUCH now it's working. so next thing I will try to put 6 more drop down in this form. I hope it will work. thanks again sebastien Link to comment https://forums.phpfreaks.com/topic/207037-why-is-doing-this/#findComment-1082688 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.