troubleshooting Question

Returning option values to form with PHP

Avatar of NZ7C
NZ7C asked on
PHP
6 Comments1 Solution323 ViewsLast Modified:
Here is a portion of my form page and the action page. The page works just fine EXCEPT it does not echo back the list of all user last names. It will echo back the number of users just fine.  
<? echo "$lastname" ?> does not work and
<? echo "$_POST[lastname]" ?> does not work. What am I doing wrong?
I know I should have this simple stuff in my head by now - but it does not seem to be sinking in. Thanks in advance for any help. I've found thiis forum to be invaluable.

PAGE NAME = ADMNIN_USER.PHP:

require_once('Includes/conn.php');
require_once('functions.php');
session_start();
check_for_valid_user();.........ETC...

 <form action="admin_search_all.php" method="post">
      <input name="searchterm" class="selector_two"   type="text" size="14" maxlength="14"></p>
    <p id="search_button2"><input type="submit" class="button" value="List ALL"></p>
 </form>
 <form >
      <p>Number of users found:<span class="empty"><? echo $_GET['msg']; ?></span></p>
            <p>      <select name="uid" class="selector_search_box" >
                <option value="$uid"><? echo "$lastname" ?></option>                                  //THIS DOES NOT ECHO
              </select></p>
            <p>Do you want to EDIT or DELETE this user?</p>
              <input type="submit" class="button" value="EDIT user profile">
            <input type="submit" class="button" value="DELETE user">
 </form>

PAGE NAME = ADMIN_SEARCH_ALL.PHP:

require_once('Includes/conn.php');
require_once('functions.php');
session_start();
check_for_valid_user();

//build and issue query
  $sql = "SELECT * FROM t_user";
  $result = mysql_query($sql,$connection) or die(mysql_error());
//check the number of results
  $num = mysql_num_rows($result);
 
while ($row = mysql_fetch_array($result))
     {
            $uid = $row['uid'];
            $firstname = $row['firstname'];
            $lastname = $row['lastname'];
            $username = $row['username'];
      }
      $msg = "$num";
      header("Location:http://www.blah_blah_blah/admin_user.php?msg=" . urlencode($msg));
?>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros