Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi all,

After working through the edit_user script in chapter ten, I thought I would like to try my hand at retrieving user information through a select dropdown. As I will have ~5000 clients, working through the list manually would be something of a chore. I came up with the following;

$query = "SELECT on_programme, last_name, first_name, middle_name, id FROM constant_client WHERE on_programme=1 ";
$result = mysqli_query($conn, $query);

echo  '<form action="selected_client.php" method="get">

echo '<p><label for="current_clients">Select Client by name: </label>
        <select id="current_clients" name="current_clients">
        <option> -- Select Client -- </option>';

        while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
          echo '<option>'.$row['id'].' '.ucwords($row['last_name']).', '.ucwords($row['first_name']).' '.ucwords($row['middle_name']).'</option>';  

echo '</select>';
      echo '<input type="submit" name="submit" value="Go!">
<input type="hidden" name="id" value="'.$row['id'].'">';

The above populates the dropdown menu, but I am receiving an "array offset type null" error on submission of the form, because the $row['id'] variable doesn't appear to be set outside the while loop.

Any suggestions would be greatly appreciated.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...