I am on the way of one accounting package using php. On my one page I want to fetch one of the attributes (full), of a table and display it as a select key.How can I do it.Now with this code I can only get the last value in that attribute.So plz help me.I want the complete values here.
you're loop is incorrect, like this : <form action="Managing.php" method="post"> <p> </p> <p> </p> <p> </p> <p> </p> <p> <center> <select name="ondate"> <? while($row=mysql_fetch_array($result)) { ?> <option value="<?php print $row['Date'];?>"><?php print $row['Date'];?></option> <?php } ?> </select> <br /><p> <input type="submit" value="Manage" /> </p> </form> PHP: I haven't checked the code, but the loop is wrong fix that first.....
the loop may well work, but as I said it is incorrect, when looping you only need to loop over html that you need more than once, so having all that html inside the while loop will not give the correct results no matter what.
<? $con=mysql_connect("localhost","root",""); if( !$con ) : mysql_error( ); exit; endif; mysql_select_db("billing"); $result=mysql_query("SELECT Date FROM `bill`"); ?> <form action="Managing.php" method="post"> <p> </p> <p> </p> <p> </p> <p> </p> <p> <center> <select name="ondate"> <? //fetching from database while( $row = mysql_fetch_assoc( $result ) ) { ?> <option value="<?=$row['Date'] ?>"><?=$row['Date'] ?></option> <? } mysql_close($con); ?> </select> <br /><p> <input type="submit" value="Manage" /> </p> </form> PHP: Give that a whirl ....