techker Posted September 22, 2017 Share Posted September 22, 2017 Hey guys i have a products site and i put an edit product page , i need to put in a form of select box the database info but highlight the result in the table.. ok so lets say product car name id type brand ---> select box to edit the brand (select * from Brands) but incase he does not want to change that info i need the default to be the info stores already? brand Honda -->select box highlight Honda this is the select i have div class="form-group"> <label for="exampleInputName2">Brand : <? echo $row['Brand'] ?></label> <select name="Brand"> <?php while ($row2 = mysqli_fetch_array($result2)) { echo "<option value='".$row2['Name']."'>".$row2['Name']."</option>"; } ?> Quote Link to comment Share on other sites More sharing options...
requinix Posted September 22, 2017 Share Posted September 22, 2017 The output you need to get is Honda Quote Link to comment Share on other sites More sharing options...
Sepodati Posted September 22, 2017 Share Posted September 22, 2017 You have the "id" of the product you're editing and each row has an "id". When they are the same, add the "selected" tag to the <option>. Quote Link to comment Share on other sites More sharing options...
techker Posted September 22, 2017 Author Share Posted September 22, 2017 this shows the list and the value echo "<option value='".$row['Name']."'>".$row['Name']."</option>"; if i put honda it waill always put the value? Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted September 22, 2017 Share Posted September 22, 2017 So...$result2 contain all the possible brand options, correct? If so, you should be able to add the "selected" attribute to the <option> tag when $row['Brand'] == $row2['Name']. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.