PHP and HTML issues

html
#1

I’m doing a project using php and HTML. In my code when I add the php part the rest of HTML part isn’t working. It would be great if you could give me a solution.

<form name="form1" action="AddItem.php" method="post">
    <div class="form-group">
         <label for="text">Item Name</label>
          <table>
               <tr>
                    <td ><select class="form-control show-tick" name="ItemName" id="ItemName" required>
                         <option value="" disabled="" onChange="GetBrand(this.value);" selected>Select Name</option>
         //After this PHP code, the HTML part isn't running.
                          <?php
                             $sql1="SELECT * FROM stockdetails";
                             $results=$dbhandle->query($sql1);
                              while($rs=$results->fetch_assoc()) { 
                               ?>
                              <option value="<?php echo $rs["ItemNot"]; ?>"><?php echo $rs["ItemName"]; ?></option>
                               <?php
                                }
                                              ?>
                              </select></td>
                              <td><label for="text">Add Item Name : </label></td>
                              <td><input type="text" name="name" id="name"  class="form-control"  </td>
                              <td><button class="btn btn-info" onclick="insertValue();">Add</button></td>
                          </tr>
                </table>
          </div>
          <div class="form-group">
               <label for="text">Brand Name</label>
               <table>
                      <tr>
                           <td><select class="form-control show-tick" name="brand" id="brand" required>
                                   <option value="">Select Brand</option>>        
                                   </select></td>
                             <td"><label for="text">Add Brand : </label></td>
                             <td><input type="text" name="Bname" id="Bname"  class="form-control" > </td>

                             <td><button class="btn btn-info" onclick="insertValueBrand();" Add</button></td>
                         </tr>
                 </table>
          </div>
</form>
#2

“isn’t working.” probably means no errors and no result? Then are you sure that your query has a rows?

1 Like
#3

Thank you for replying me.I checked it. But I couldn’t find any… After that php part the rest of the part doesn’t work.

#4

what should that mean for anybody? Have a look in the error log if no error is displayed. At least $dbhandle is undefined.

1 Like
#5

Is your error reporting on? If no, add at start of php:

error_reporting(E_ALL);
ini_set("display_errors", 1);
1 Like
#6

@chorn Thank you so much for replying me… :cry: I defined it… I didn’t add that part here… The code is to long… That’s why didn’t.

#7

@igor_g okay… I’ll do it now…

#8

You have a number of missing close-tag > characters, is that just in the posted code, or in the real code as well?

But as several have said, you need to be more clear about what you mean with “doesn’t work”. For example, if you right-click the browser, how much of the HTML after the point at which you say it stops is there? Is it present but not rendering, or not present at all?

<option value="" disabled="" onChange="GetBrand(this.value);" selected>Select Name</option>

Can you have an onChange parameter on an <option>? Shouldn’t it be on the <select>?

2 Likes
#9

@droopsnoot @igor_g @chorn… Thank you all…