treeleaf20
01-12-2010, 04:33 PM
All,
I have the following code:
<?php
$qrypic = "Select * from pictures where picture_id='$picid'";
$resultpic = mysql_query($qrypic);
$resultsetpic = mysql_fetch_array($resultpic);
?>
<select name="job">
<?php
$qryjobs = "Select job_id, name from jobs order by name ASC";
$resultjobs = mysql_query($qryjobs);
while($resultsetjobs = mysql_fetch_array($resultjobs)){
if($resulsetjobs['job_id'] == $resultsetpic['job_id']){
?>
<option value="<?php echo $resultsetjobs['job_id']; ?>" selected><?php echo $resultsetjobs['name']; ?></option>
<?php
}else{
?>
<option value="<?php echo $resultsetjobs['job_id']; ?>"><?php echo $resultsetjobs['name']; ?></option>
<?php
}
}
?>
</select>
It should make the row that matches selected but for some reason it's not working. Can anyone see what I'm doing wrong?
Thanks in advance.
I have the following code:
<?php
$qrypic = "Select * from pictures where picture_id='$picid'";
$resultpic = mysql_query($qrypic);
$resultsetpic = mysql_fetch_array($resultpic);
?>
<select name="job">
<?php
$qryjobs = "Select job_id, name from jobs order by name ASC";
$resultjobs = mysql_query($qryjobs);
while($resultsetjobs = mysql_fetch_array($resultjobs)){
if($resulsetjobs['job_id'] == $resultsetpic['job_id']){
?>
<option value="<?php echo $resultsetjobs['job_id']; ?>" selected><?php echo $resultsetjobs['name']; ?></option>
<?php
}else{
?>
<option value="<?php echo $resultsetjobs['job_id']; ?>"><?php echo $resultsetjobs['name']; ?></option>
<?php
}
}
?>
</select>
It should make the row that matches selected but for some reason it's not working. Can anyone see what I'm doing wrong?
Thanks in advance.