jkkenzie Posted July 16, 2008 Share Posted July 16, 2008 $result2 = mysql_query("SELECT DISTINCT strHomeDistrict FROM `home districts` ORDER BY strHomeDistrict"); echo "<select name='Home District'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[strHomeDistrict]'"; if($nt[strHomeDistrict] == $strHomeDistrict) { echo " selected"; } echo ">$nt[strHomeDistrict]</option>"; } echo "</select>"; The code above which is found in below part of full code is working well but when executed, the part"{ echo " selected"; }" seems to put the result outside the listbox instead of inside. <?php function showroweditor($row, $iseditmode) { global $conn; ?> <table class="tbl" border="0" cellspacing="1" cellpadding="3"width="50%"> <tr><?php echo $_POST['ID']."<br>"; echo $_POST['xID']."<br>"; ?> <td class="hr"><?php echo htmlspecialchars("Receipt Number")." " ?></td> <td class="dr"><input type="text" name="Receipt_Number" maxlength="255" value="<?php echo str_replace('"', '"', trim($row["Receipt Number"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Title")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT TITLE FROM titles ORDER BY TITLE"); echo "<select name='Title'>"; while($nt=mysql_fetch_array($result2)){ echo "<option name='Title' value='$nt[TITLE]'"; if($nt[TITLE] == $Title) { echo " selected"; } echo ">$nt[TITLE]</option>"; } echo str_replace('"', '"', trim($row["Title"])); echo "</select>"; ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("First Name")." " ?></td> <td class="dr"><input type="text" name="First_Name" maxlength="255" value="<?php echo str_replace('"', '"', trim($row["First Name"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Middle Name")." " ?></td> <td class="dr"><input type="text" name="Middle_Name" maxlength="255" value="<?php echo str_replace('"', '"', trim($row["Middle Name"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Last Name")." " ?></td> <td class="dr"><input type="text" name="Last_Name" maxlength="255" value="<?php echo str_replace('"', '"', trim($row["Last Name"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Reg Fees")." " ?></td> <td class="dr"><input type="text" name="Reg_Fees" value="<?php echo str_replace('"', '"', trim($row["Reg Fees"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Date Registered")." " ?></td> <td class="dr"><input type="text" name="Date_Registered" value="<?php echo str_replace('"', '"', trim($row["Date Registered"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("ID Number")." " ?></td> <td class="dr"><input type="text" name="ID_Number" maxlength="255" value="<?php echo str_replace('"', '"', trim($row["ID Number"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Y O B")." " ?></td> <td class="dr"><input type="text" name="Y_O_B" maxlength="50" value="<?php echo str_replace('"', '"', trim($row["Y O B"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Home District")." " ?></td> <td class="dr"> <?php $result2 = mysql_query("SELECT DISTINCT strHomeDistrict FROM `home districts` ORDER BY strHomeDistrict"); echo "<select name='Home District'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[strHomeDistrict]'"; if($nt[strHomeDistrict] == $strHomeDistrict) { echo " selected"; } echo ">$nt[strHomeDistrict]</option>"; } echo "</select>"; echo str_replace('"', '"', trim($row["Home District"])); ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Telephone")." " ?></td> <td class="dr"><input type="text" name="Telephone" maxlength="50" value="<?php echo str_replace('"', '"', trim($row["Telephone"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Cell Phone")." " ?></td> <td class="dr"><input type="text" name="Cell_Phone" maxlength="50" value="<?php echo str_replace('"', '"', trim($row["Cell Phone"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Address")." " ?></td> <td class="dr"><input type="text" name="Address" maxlength="255" value="<?php echo str_replace('"', '"', trim($row["Address"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("E-mail")." " ?></td> <td class="dr"><input type="text" name="E-mail" maxlength="255" value="<?php echo str_replace('"', '"', trim($row["E-mail"])) ?>"></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Receipt Issued")." " ?></td> <td class="dr"><input type="checkbox" name="Receipt_Issued"/></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Gender")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT SEX FROM gender ORDER BY SEX"); echo "<select name='Gender'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[sEX]'"; if($nt[sEX] == $strSex) { echo " selected"; } echo ">$nt[sEX]</option>"; } echo "</select>"; echo str_replace('"', '"', trim($row["Gender"]))?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Occupation")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT DISTINCT Occupation FROM members ORDER BY Occupation"); echo "<select name='Occupation'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='--- Select Occupation ---'>$nt[Occupation]</option>"; } echo "</select>"; ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Employer")." " ?></td> <td class="dr"><textarea cols="35" rows="4" name="Employer" maxlength="255"><?php echo str_replace('"', '"', trim($row["Employer"])) ?></textarea></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Division")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT DISTINCT strDivision FROM divisions ORDER BY strDivision"); echo "<select name='Division'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[strDivision]'"; if($nt[strDivision] == $strDivision) { echo " selected"; } echo ">$nt[strDivision]</option>"; } echo str_replace('"', '"', trim($row["Division"])); echo "</select>"; ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Location")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT DISTINCT strLocation FROM locations ORDER BY strLocation"); echo "<select name='Location'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[strLocation]'"; if($nt[strDivision] == "--- Select Location ---") { echo " selected"; } echo ">$nt[strLocation]</option>"; } echo str_replace('"', '"', trim($row["Location"])); echo "</select>"; ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("SubLocation")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT DISTINCT strSubLocation FROM sublocations ORDER BY strSubLocation"); echo "<select name='SubLocation'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[strSubLocation]'"; if($nt[strDivision] == "--- Select Sublocation ---") { echo " selected"; } echo ">$nt[strSubLocation]</option>"; } echo str_replace('"', '"', trim($row["SubLocation"])); echo "</select>"; ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Country")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT DISTINCT strCountry FROM countries ORDER BY strCountry"); echo "<select name='Country'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[strCountry]'"; if($nt[strDivision] == "--- Select Country ---") { echo " selected"; } echo ">$nt[strCountry]</option>"; } echo str_replace('"', '"', trim($row["Country"])); echo "</select>"; ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Country Of Residence")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT DISTINCT strCountryOfResidence FROM `country of residence` ORDER BY strCountryOfResidence"); echo "<select name='Country Of Residence'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[strCountryOfResidence]'"; if($nt[strDivision] == "--- Select Country Of Residence ---") { echo " selected"; } echo ">$nt[strCountryOfResidence]</option>"; } echo str_replace('"', '"', trim($row["Country Of Residence"])); echo "</select>"; ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Form Of Payment")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT DISTINCT strFormOfPayments FROM `form of payment` ORDER BY strFormOfPayments"); echo "<select name='Form Of Payment'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[strFormOfPayments]'"; if($nt[strDivision] == "--- Select Form of Payment ---") { echo " selected"; } echo ">$nt[strFormOfPayments]</option>"; } echo str_replace('"', '"', trim($row["Form Of Payment"])); echo "</select>"; ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Bank")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT DISTINCT strBanks FROM `banks` ORDER BY strBanks"); echo "<select name='Bank'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[strBanks]'"; if($nt[strDivision] == "--- Select Bank ---") { echo " selected"; } echo ">$nt[strBanks]</option>"; } echo str_replace('"', '"', trim($row["Bank"])); echo "</select>"; ?></td> </tr> <tr> <td class="hr"><?php echo htmlspecialchars("Current Residence")." " ?></td> <td class="dr"><?php $result2 = mysql_query("SELECT DISTINCT `Current Residence` AS strres FROM `members` ORDER BY `Current Residence` "); echo "<select name='Current Residence'>"; while($nt=mysql_fetch_array($result2)){ echo "<option value='$nt[strres]'"; if($nt[strDivision] == "--- Select Current Residence ---") { echo " selected"; } echo ">$nt[strres]</option>"; } echo str_replace('"', '"', trim($row["Current Residence"])); echo "</select>"; ?></td> </tr> </table> <?php } ?> <?php function showpagenav($page, $pagecount) { ?> <table class="bd" border="0" cellspacing="1" cellpadding="4"> <tr> <td><a href="index.php?a=add">ADD</a> </td> <?php if ($page > 1) { ?> <td><a href="index.php?page=<?php echo $page - 1 ?>"><< PREVIOUS</a> </td> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/115006-solved-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.