php - x-editable select with options value from mysql database -


so i'm using x-editable bootstrap, awsome me.

can me how set option values mysql database x-editable select options

this php code

$result1 = ("select * users type='agent'") or mysql_error();      $users=mysql_query($result1);         while($rowa = mysql_fetch_array($users)){          ?>         <option name="agent" value = "<?php echo $rowa['username']; ?>" >             <?php echo $rowa['username']; ?>         </option>     <?php     } ?> 

so you're going want create json string put anchor element. let's see looks like.

first, need push usernames array object it, json encode it. that'll this:

$usernames = array(); while(.....){     $usernames[] = $rowa['username']; } $usernames = json_encode($usernames);  <a href="#"      id="username" //your reference      data-type="select" //so x-editable library makes select list     data-name="username"      data-pk="1"      data-value="5"      data-original-title="select username"      data-source="<?php echo $usernames?"> //this json array of usernames.  ">     username </a> 

and produce select list of usernames.

here's functioning jsfiddle


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -