Jump to content


This topic is now archived and is closed to further replies.


While Loop and combo box

Recommended Posts

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 button

heres my code:

    $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\">

        <select name=\"membership_no\">

        <INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Select this Member\"></P>

<TITLE>User Management</TITLE>
<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"; ?>


Thanks to anyone that can help


Share this post

Link to post
Share on other sites

the 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 db


Share this post

Link to post
Share on other sites
i solved the problem

i 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

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.