javascript - Dynamically values parse to Popup Model Box from PHP Page -


i trying parse php data values inside while loop popup model .

sample code

<?php include("connect.php");  $sql = 'select id products tag="mixed" order id desc limit 5';  mysql_select_db('levels'); $retval = mysql_query( $sql, $db_server ); if(! $retval ) {   die('could not data: ' . mysql_error()); } while($row = mysql_fetch_array($retval, mysql_assoc)) {   $id = $row['id'];    ?>  <div onclick="showdialog('#dialog6');show_data();">    <div id="getid">     <?php echo $id; ?>   </div>  </div>  <?php } mysql_close($db_server); ?>   <script>     function showdialog(id){         var dialog = $(id).data('dialog');         dialog.open();     }      function show_data(){       var x = document.getelementbyid("getid").innerhtml;       document.getelementbyid("demo").innerhtml = x; } </script>  <!-- popup model --> <div data-role="dialog" id="dialog6" >  <div id="demo"> </div>  </div> 

let's if have id => 1 10 , above code writing last 5 items table. 6 7 8 9 10 . ( it's working ) .

my requirement when click 7 should parse 7 popup model. ( or let's innerhtml of ).

it parsing first value ( 5 ) . onclick events when click each number.

ps : test using mysql not mysqli or pdo :) .

thanks in advance !

try this. hope helps.

    $sql = 'select id products tag="mixed" order id desc limit 5';      mysql_select_db('levels');     $retval = mysql_query( $sql, $db_server );     if(! $retval )     {       die('could not data: ' . mysql_error());     }     while($row = mysql_fetch_array($retval, mysql_assoc))     {       $id = $row['id'];        ?>      <div onclick="showdialog('#dialog6');show_data(<?php echo $id; ?>);"> <!-- changed -->        <div id="getid<?php echo $id; ?>"> <!-- changed -->         <?php echo $id; ?>       </div>      </div>      <?php     }     mysql_close($db_server); ?>   <script>     function showdialog(id){        var dialog = $(id).data('dialog');        dialog.open();     }      function show_data(y){ // changed      var x = document.getelementbyid("getid"+y).innerhtml; // changed      document.getelementbyid("demo").innerhtml = x; } </script>  <!-- popup model --> <div data-role="dialog" id="dialog6" >  <div id="demo"> </div>  </div> 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -