Malcolmhire2001 Posted May 23, 2006 Share Posted May 23, 2006 Hello, i am trying to make a form where you can select a member from a combo box then you would be able to edit there details, using a while loop.all that is happening is that it there is a empty combo box and the buttonheres my code:[code]<?php include("connection.inc.php"); $connection = connect(); $sql = "SELECT membership_no, forename, surname, address_1, address_2, post_code, telephone_no FROM tbl_members ORDER BY surname"; $result = @mysql_query($sql) or die (mysql_error()); $option_block = ""; while ($row = mysql_fetch_array($result)) { $membership_no = $row['membership_no']; $forename = $row['forename']; $surname = $row['surname']; $address_1 = $row['address_1']; $address_2 = $row['address_2']; $postcode = $row['post_code']; $telephone_no = $row['telephone_no']; $option_block .= "<option value=\"$membership_no\"> $membership_no, $forename, $surname, $address_1, $address_2, $post_code, $telephone_no</option>"; } $display_block = " <FORM METHOD=\"post\" ACTION=\"index.php?page=show_existing.php\"> <P><strong>Contact:</strong> <select name=\"membership_no\"> $option_block </select> <INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Select this Member\"></P> </form> ";?><HTML><HEAD><TITLE>User Management</TITLE></HEAD><BODY><h1>User Management</h1><h3>Modify a User</h3><P>Select a user from the list below, to modify the user's record.</p><? echo "$display_block"; ?></BODY></HTML>[/code]Thanks to anyone that can helpMalcolm Quote Link to comment https://forums.phpfreaks.com/topic/10257-while-loop-and-combo-box/ Share on other sites More sharing options...
samshel Posted May 23, 2006 Share Posted May 23, 2006 Hellothe code seems the be correct....try removing the @ sign from mysql_query()also try, $result = @mysql_query($sql) or die (mysql_error()); $num = mysql_num_rows($result); echo $num;//this will display no of records..if there are any in the dbhth Quote Link to comment https://forums.phpfreaks.com/topic/10257-while-loop-and-combo-box/#findComment-38209 Share on other sites More sharing options...
Malcolmhire2001 Posted May 23, 2006 Author Share Posted May 23, 2006 i solved the problemi stupidly had no data in the SQL table [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] thanks anyway Quote Link to comment https://forums.phpfreaks.com/topic/10257-while-loop-and-combo-box/#findComment-38223 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.