php - Dynamic data in dropdown from database in Wordpress -
i looking have googled , spent lot of time did not find proper solution here. want populate dropdown database using $wpdb-getresults() method.
here code:
<?php /* template name: custom page */ get_header(); ?> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"> $(document).ready( function () { $("#selector").change( function() { alert("o allah me"); }); }); </script> <?php function show_list() { $output = ''; $results = $wpdb->get_results( " select * items "); while ($results) { $output .= '<option value="'.$results["id"].'"> '.$results["p1"].' </option>'; } return $output; } ?> select question: <select id="selector"> <?php echo show_list(); ?> </select><br><br> <div id="result"> <input type="text" name="p1" value="<?php echo $p1 ?>" /> <input type="text" name="p2" value="<?php echo $p2 ?>" /> <input type="text" name="p3" value="<?php echo $p3 ?>" /> <input type="text" name="p4" value="<?php echo $p4 ?>" /> <input type="text" name="p5" value="<?php echo $p5 ?>" /> </div> <?php get_footer(); ?>
Comments
Post a Comment