Get selected drop down

Dharmeshdhabu

New member
I have similar problem.
I have one tab source from where I fatch value from column 'Pathology' into option and then insert into another table bdaily column 'Pathology'. Till here it is working fine . But in view I want to fatch same inserted value from bdaily column 'Pathology' and get it selected in dropdown. I tried above code given by you but it donot work. Selected value comes last row which is blank. Please guide me.

Here is my code.

Code:
<td style="padding:10px;">Pathology</td>
										<td>
											<?php $results = mysqli_query($conn, "SELECT * FROM source where Pathology is not null"); ?>
												<select class="form-control" name="Pathology" value="<?php echo trim($Pathology); ?>"  id="Pathology">
														<?php while ($row = mysqli_fetch_array($results)) { ?>
														<option data-id="<?php echo $row['PAmount']; ?>" value="<?php echo $row['Pathology']; ?>"
														<?php if($row['Pathology']==$row['Pathology']);
														{
															echo "selected";
														}
														
														?>
														><?php echo $row['Pathology']; ?>
														</option>
														
														
														<?php } ?>	
													</select>
										</td>
 
Code:
if($row['Pathology']==$row['Pathology']);
It will be allays true, and the semicolon is not needed, I think you need this:
Code:
if($row['Pathology']==$Pathology)
 
Michalio said:
Code:
if($row['Pathology']==$row['Pathology']);
It will be allays true, and the semicolon is not needed, I think you need this:
Code:
if($row['Pathology']==$Pathology)

Wonderfull!
A small correction helped me a lot.
Thanks for quick and accurate help.
 
Back
Top