Hi,
I am having two problewms. The first is in getting data from a row in a database into a dropdown on a form. I can get the data but the dropdown defaults th Novice not the Extra which is in the table.

The second is writing the data back to the row in the table.
Here is what I have, I am not familiar with the way I should post this:

<?php 
session_start();

if (!isset($_SESSION['user']))
{
header("Location: login.php");
}

include ('dbc.php'); 

if ($_POST['Submit']=='Change')
{
$rsPwd = mysql_query("select user_pwd from users where user_email='$_SESSION[user]'") or die(mysql_error());

  mysql_query("Update users
  				SET full_name = '$full_name'
				WHERE user_email = '$_SESSION[user]'
				") or die(mysql_error());
  header("Location: settings.php?msg=Settings updated...");				
  } 

?>

<?php
$result = mysql_query ("SELECT * FROM users  
WHERE user_email LIKE '$_SESSION[user]'
"); if ($row = mysql_fetch_array($result)) { do { $checkfullname = $row['full_name']; $checkname = $row['user_name']; $checkemail = $row['user_email']; $checkclass = $row['l_class']; $checkcall = $row['call_sign']; PRINT "<b>Username: </b> ";
print $row["full_name"];
print (" ");
print ("<br>");
PRINT "<b>Name: </b> ";
print $row["user_name"];
print ("<br>"); PRINT "<b>Email: </b> ";
print $row["user_email"];
print ("<br>");
PRINT "<b>Class: </b> ";
print $row["l_class"];
print ("<br>"); PRINT "<b>Call Sign: </b> ";
print $row["call_sign"];
print ("<br>"); } while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found!";}
?> <?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?> </p> <table width="65%" border="0" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="d5e8f9" class="mnuheader"><strong><font size="5">Edit Account for <?php print $_SESSION[user] ?> </font></strong></td> </tr> <tr> <td bgcolor="e5ecf9" class="forumposts"><form name="form1" method="post" action="register.php" style="padding:5px;"> <p><br> Name: <input type="text" name="full_name" id="full_name" value="<?= $checkfullname ?>" /> Ex. John Wilson</p> User Name: <input name="user_name" type="text" id="user_name" value="<?= $checkname ?>" />Ex. John </p> <p>Email: <input name="email" type="text" id="email" value="<?= $checkemail ?>" /> Ex. [email]john@domain.com[/email]</p> </p> <p>Class: <select name="l_class" id="select8" value="<?= $checkclass ?>" ;"/> <option value="None">None</option> <option value="Novice">Novice</option> <option value="Tech">Tech</option> <option value="HF Tech">HF Tech</option> <option value="General">General</option> <option value="Advanced">Advanced</option> <option value="Extra">Extra</option> </select> </p> <p>Call Sign: <input name="call_sign" type="text" id="call_sign" value="<?= $checkcall ?>" /> </p> <input name="user_code" type="text" size="10"> <img src="pngimg.php" align="middle">&nbsp; </p> <p align="center"> <input type="submit" name="Submit" value="Update"> </p> </form></td> </tr>

    If you want a specific value as the default selected dropdown value, you need to set the attribute "selected" on the specific <option> tag you want. For example, to make "Advanced" the default you would use the following HTML:

    <select name="l_class" id="select8">
    <option value="None">None</option>
    <option value="Novice">Novice</option>
    <option value="Tech">Tech</option>
    <option value="HF Tech">HF Tech</option>
    <option value="General">General</option>
    <option value="Advanced" selected="selected">Advanced</option>
    <option value="Extra">Extra</option>
    </select>

    Right now your query is just updating the full name based on the email address. To update any other fields, you need to specify the fields and values in the "SET" area of the query. E.g.:

    UPDATE <<table_name>>
    SET <<field>>=<<value>>, <<field2>>=<<value2>>, <<field3>>=<<value3>>
    WHERE <<somefield>>=<<somevalue>>

    So to update a bunch of fields, you can either run a bunch of UPDATE queries, or one with the fields all specified like above.

      Write a Reply...