Wednesday 15 June 2011

Pull the data from mysql in PHP page and show in dropdown in html page -



Pull the data from mysql in PHP page and show in dropdown in html page -

i have created html page . here code this:

<title>post ad</title> </head> <body> <form method="post" action="postad.php"> <table> <tr> <td>adname:</td> <td><input type="text" name="adname"></td> </tr> <tr> <td>adcategory</td> <td> <select name="categories"> <?php include 'getcategories.php'; echo '<option value="'.$categoryname.'">'.$categoryname.'</option>'; ?> </select>"; </td> </tr> <tr> <td>contact number</td> <td><input type="text" name="contactnumber"></td> </tr> <tr> <td>image</td> <td><input type="text" name="image"></td> </tr> <tr> <td>description</td> <td><input type="text" name="description"></td> </tr> <tr> <td>expiration date</td> <td><input type="text" name="expirationdate"></td> </tr> <tr> <td id="btn"><input type="submit" value='submit' name="submit"></td> </tr> </table> </form> </body> </html>

and have php page getcategories.php

<?php include 'connect.php'; $sql = "select catname categories order catname"; $result = $db->query($sql); // $options=""; //echo "<select value='categories'>"; while($row = $result->fetch_array()) { $categoryname=$row['catname']; //echo "$categoryname\n"; //$options= '<option value="'.$categoryname.'">'.$categoryname.'</option>'; // echo "$options\n"; // echo '<option value="'.$categoryname.'">'.$categoryname.'</option>'; } // echo "</select>"; ?>

the main objective of getcategories.php page pull info database , page postad.html page show info of getctegories.php dropdown list in postad.html.is there way not utilize java script , utilize php , mysql this?please help. give thanks you.

php html mysql

No comments:

Post a Comment