Jump to content

Select Distinct if existing


chaosuk

Recommended Posts

Hi guys,

 

using the code below within an admin panel to create a drop down allowing the user to select the profiles they wish to assign to the record they're creating, problem we have is that once a record is created, if they need to edit it for what ever reason the selected profile option isn't sticking. I've played around with lots of variants of if existing_record to try and get it add selected="selected" into the code but failed at every attempt, any advice gratefully received.

 

<?php

// List only breeder profiles in the database

  echo '<select name="profile" class="textinput noborder">';
  echo '<option value="any">Any</option>';

        $qryGetDistinctProfile = "SELECT * FROM profiles ORDER BY title ASC";
        $resGetDistinctProfile = mysql_query($qryGetDistinctProfile,$connection) or die(mysql_error());

        if(mysql_num_rows($resGetDistinctProfile) > 0){

		$id       =  mysql_result($resProfile, 0, "id");
          
         while ($row = mysql_fetch_assoc($resGetDistinctProfile)){
		           
          echo  '<option value="'.$row['id'].'" >'.$row['title'].'</option>';

         }

        }

  echo '</select>';
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.