Jump to content

[SOLVED] Bamboozled. cannot figure out the error.


Johnain

Recommended Posts

try this out

 

<?php
require('db_connect.php');    // database connect script.
?>
<html>
<head>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

  <!-- saved from url=(0014)about:internet -->
  <?php
  $langg = $_GET['langg'];
  include_once($_SERVER['DOCUMENT_ROOT'].'/scripts/incgetvars.php');
  switch ($langg)
  {   
    case "FR":
       echo"<title>Le Pré De Barre. Zone du personnel, maintenez l'utilisateur.</title>" ;
       break;
    default:
      echo "<title>Le Pré De Barre. Staff zone, maintain user.</title>" ;
  }
  ?>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link href="../css/style1.css" rel="stylesheet" type="text/css" />
</head>
<body>

  <div id="header">
    <div id="sitebranding">
      <?php      
       include_once($_SERVER['DOCUMENT_ROOT'].'/scripts/incsitebrand.php');
       ?>
    </div> <!-- End of site branding div -->
   <div id="tagline">
    <?php
     include_once($_SERVER['DOCUMENT_ROOT'].'/scripts/inctagline.php');
      ?>
     </div> <!-- End of tagline div -->
   </div> <!-- end of header div -->
   <div id="navigation">
      <?php
      $noshow =40;
      include_once($_SERVER['DOCUMENT_ROOT'].'/scripts/incgetnav.php');
       ?>
  </div> <!-- end of navigation div -->
  <div id="bodycontentstaff">
  <?php
  
   
   if (!isset($_POST['submit'])) 
   {          // If form has not been submitted this must be step 1
   $stepno = 1;                                       
   switch ($stepno) 
   {
   case 1:                                   // Start step 1. Ask which user to maintain.            
  $query = "SELECT username FROM users" ;
      $result=mysql_query($query);
      $num=mysql_num_rows($result);
      ?>
      <h4>User maintenance - select user.</h4>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
      <table align="center" border="1" cellspacing="0" cellpadding="3">
         <tr>
            <td>User name?</td>
            <td><select name="uname">
            <?php
        
              while ($row = mysql_fetch_assoc($result)) {
	         echo "<option value='{$row['username']}' >{$row['username']}</option>";
           }
          ?>
         </select>
       </td>
   </tr>
   <tr>
      <td colspan="2" align="right">
      <input type="submit" name="submit" value="<?php echo $buttontext; ?>">
       </td>
              </tr>
             </table>
         </form>
       <?php
       break;
    case 2:                                                         // Start step 2. User details maintenance.
        break;
    case 3:                                                        // Start step 3. Changed details are saved or abandoned.
        break;
   }
  }
   
   ?>

</div> <!-- end of bodycontentstaff -->

</body>
</html>


Link to comment
Share on other sites

Yippee. I have solved it.

 

The data was coming in, but my drop down box was a mess.

 

If it is any help to anybody else, here is my solution !!! It was frustrating, but now I will remember it.

 

 

$query = "SELECT username FROM users" ;

      $result=mysql_query($query);

      $num=mysql_num_rows($result);

      ?>

<p>Number of users : <? echo($num); ?></p>

<p><? echo(mysql_result($result,0)); ?></p>

      <form method="post">

      <table align="center" border="1" cellspacing="0" cellpadding="3">

        <tr>

            <td>User name?</td>

            <td><select name="uname">

            <?php

       

            $i=0;

      while ($i < $num) {

$linetext = "<option value= ' ".mysql_result($result,$i)." ' >".mysql_result($result,$i)."</option>";

echo( $linetext);

$i++;

          }

          ?>

 

          </select>

        </td>

      </tr>

      <tr>

          <td colspan="2" align="right">

<input type="submit" name="submit" value="Select">

          </td>

      </tr>

    </table>

  </form>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

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.