Jump to content

Solved (thanks)outputting incorrectly.


Ninjakreborn

Recommended Posts

[code]<select name="status" id="status">
<option value="none">Please Select One</option>
<?php
// get list of status's
$selectstat = "SELECT * FROM oak_status;";
$querystat = mysql_query($selectstat);
// run query and display them
while ($rowstat = mysql_fetch_array($querystat)) {
echo "<option value=\"{$rowstat[statNo]}\"" . tempvar($rowstat['statNo'], $row['statNo']) . ">{$rowstat[status]}</option>\n"; // display them all
}
?>
</select><br />[/code]

function
[code]<?php
// Function Start:
// Function Name: tempvar()
// Function Parameters: 2
// Function Process: This function is used for form's when it come's to making
// the form drop down menu's stick.  This will allow it to pre-populate drop down menus
function tempvar($variable, $testvariable) {
if ($variable == $testvariable) {
echo 'selected="selected"';
}
}
// end function
?>
[/code]

This is the function I am trying to use to get the drop down menu to 'remember' what was selected from the database.  I used this on another project, so I created this function, for now, it's technically working in theory like it's suppose to, but for some wierd reason, it output's it in the wrong area, based on the code at the top, it's outputting the following.  I am seeing this inside the html source code.

[quote]<label for="status">*Status:</label><br />
<select name="status" id="status">
<option value="none">Please Select One</option>
selected="selected"<option value="7">Complete - Portfolio</option>
<option value="6">temp status</option>
<option value="3">NOW!</option>
<option value="4">Available Spring 2007</option>

</select><br />[/quote]
You see how it's outputing the select area somewhere inf ront of the option, I looked at the programming multiple time's, it should be outputting it inside the <option> like it should be
<option value="7" selected="selected">Status Name</option>
On whichever one was actually selected.
But for some reason this isn't working, and I can't get it to output right.
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.