Jump to content

Recommended Posts

Hello All,

    I have a question about this drop down box and pulling from MySQL.

I would like to have it auto select the person in the drop down box. But I need it

This is what I would like but it does not work.

 

$Owners = "$Contactfname, $Contactlname";

$selected = ($row150['UserFirstName']","$row150['UserLastName']==$Owners )?" selected=\"selected\"":"";

 

Is there something I am missing?

 

$Owners = "$Contactfname, $Contactlname";

    <td><strong>Owner:</strong></td>
    <td>
       <select name=\"ContactOwner\" size=\"1\">";
          
$sql150 = "SELECT UserFirstName, UserLastName FROM users";
//$sql150 = "SELECT CompState FROM standardvalues";
if ($result150 = mysql_query($sql150)) {
  while ($row150 = mysql_fetch_assoc($result150)) {
    $selected = ($row150['UserFirstName']==$Owners )?" selected=\"selected\"":"";
   echo "<option value=\"{$row150['UserFirstName']}, {$row150['UserFirstName']}\"{$selected}>{$row150['UserFirstName']}, {$row150['UserFirstName']}</option>";
  }
}

echo      " </select>
      </div></td>

In this line:

$Owners = "$Contactfname, $Contactlname";

 

You have a space after the comma.

 

In this line:

$selected = ($row150['UserFirstName']","$row150['UserLastName']==$Owners )?" selected=\"selected\"":"";

 

You dont.

 

Personally i'd use an AND operator anyway:

 

$selected = ($row150['UserFirstName'] == $Contactfname && $row150['UserLastName']==$Contactlname )?" selected=\"selected\"":"";

 

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.