Imtehbegginer Posted February 18, 2007 Share Posted February 18, 2007 I am developing a script for a game, and I was wondering, how I can get the "Character Names" printed into a select menu, one by one, doesnt matter what values. But here is my code. <?php $ptr = mysql_query("SELECT * FROM characters WHERE account_name = '".$_POST['user']."'"); $chardata = mysql_fetch_array($ptr); $str = $chardata['str']; $dex = $chardata['dex']; $con = $chardata['con']; $int = $chardata['_int']; ?> The account name is in a row with char_name, how can I print it into a <select><option></select></option> menu? AND when you select it, make it go to a certain page? Link to comment https://forums.phpfreaks.com/topic/38988-little-help-please/ Share on other sites More sharing options...
spfoonnewb Posted February 18, 2007 Share Posted February 18, 2007 Like this? <?php mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $result = mysql_query("SELECT * FROM characters WHERE account_name = '".$_POST['user']."'")or die(mysql_error()); echo "<select>"; while($row = mysql_fetch_array( $result )) { echo "<option>"; echo $row['character']; echo "</option>"; } echo "</select>"; ?> Would output each value in a <option></option> and all of those would be between a <select></select> Link to comment https://forums.phpfreaks.com/topic/38988-little-help-please/#findComment-187830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.