Jump to content

Drop down problem when using a function plz help


Romeomussluv

Recommended Posts

Can some body help me with this drop down list function?

 

I'm new to PHP and any help is greatly appreciated.

i created a function to pull data from mySQL and then create a drop down box to display it.  for some reason, the options are not in the drop down, they are text outside of the dropdown.

 

Below is the script that i use.

 

/**************

 

function displayUsersDropDown($Where){

  global $database;

  $q = "SELECT username "

      ."FROM ".TBL_USERS;

 

  $q = $q." ".$Where." ORDER BY userlevel DESC,username";

  $result = $database->query($q);

  /* Error occurred, return given name by default */

  $num_rows = mysql_numrows($result);

  if(!$result || ($num_rows < 0)){

      echo "<option value=\"Error displaying info\">Error displaying info</option>";

      return;

  }

  if($num_rows == 0){

      echo "<option value=\"Database table empty\">Database table empty</option>";

      return;

  }

  echo "<select>";

  /* Display table contents */

  for($i=0; $i<$num_rows; $i++){

      $uname = mysql_result($result,$i,"username");

      echo "<option value=\"".$uname."\">$uname</option>";

  }

  echo "</select>";

}

**************/

 

the text come out like this

<select name="deluser"><option value="rngo11@clearonedebt.com">rngo11@clearonedebt.com</option><option value="rngo1@clearonedebt.com">rngo1@clearonedebt.com</option><option value="rngo@clearonedebt.com">rngo@clearonedebt.com</option></select><input type="hidden" name="subdeluser" value="1">

 

i tried other editor and the options show up in the dropdown while my page does not show them int he dropdown.  Am I doing something wrong?

 

Thank you for your help in advance.

 

 

Link to comment
Share on other sites

view the page source and show it here

 

here it is.  I removed some junk at the bottom of the problem part.

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<html>

<head>

<title>Admin Center - ClearOne Debt Relief</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="Copyright" content="ClearOne Debt Relief 2008" />

<meta name="description" content="">

<link rel="shortcut icon" type="images/ico" href="http://clearonedebt.com/images/favicon.ico" />

<link rel="stylesheet" type="text/css" href="http://clearonedebt.com/css/style.css" media="screen" />

<link rel="stylesheet" type="text/css" href="http://clearonedebt.com/css/print.css" media="print" />

<link rel="stylesheet" href="http://clearonedebt.com/admin/css/style.css" />

</head>

<body >

<table>

<tr><td>

<div id="wrapper">

<div id="container">

<div id="header">

<div id="logo"><a href="http://clearonedebt.com/"><img src="http://clearonedebt.com/images/logo-sml.jpg" alt="ClearOne Debt Services - Get out of Debt" border="0" width="800" height="118" /></a></div>

<div id="menu">

<ul>

<li id="home"><a href="http://clearonedebt.com/">Home</a></li>

<li id="aboutus"><a href="http://clearonedebt.com/about-us/">About Us</a></li>

<li id="debtrelief"><a href="http://clearonedebt.com/debt-relief-details/">Details</a></li>

<li id="faq"><a href="http://clearonedebt.com/faq/">FAQ</a></li>

<li id="applynow"><a href="http://clearonedebt.com/apply/">Apply Now</a></li>

<li id="client" class="menu_last"><a href="http://clearonedebt.com/client-services/">Client Services</a></li>

</ul>

</div>

<div id="tagline_header">Your clear path to being debt free.</div><div id="phone_header">Call us (888) 785-5376</div>

<div id="chat_header"><!-- BEGIN HelpOnClick CODE -->

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>

<TR><TD>

<SCRIPT language='JavaScript'> 

var hoc_u = 7385;

var hoc_usrnme = 'clearone';

var hoc_mode = 'image';

var hoc_image_online = 'http://clearonedebt.com/images/chat-online-redlink-two.gif';

var hoc_image_offline = 'http://clearonedebt.com/images/chat-offline-redlink.gif';

</SCRIPT>

<SCRIPT language='JavaScript' src='http://vic.static.helponclick.com/import.hoc'></SCRIPT>

<div style='z-index:99;position:absolute;visibility:hidden;display:none;left:0;top:0'><a href='http://www.helponclick.com'><font size='1'>Live Chat</font></a></div>

</TD></TR></TABLE>

<!-- END HelpOnClick CODE --></div>

</div>

<div id="content"></td><td><tr>

                                    <td valign="top" style="background-image:url(http://clearonedebt.com/images/secondary_main_vert_bg.gif); background-repeat:repeat-x;"><div class="admin_menu">

<h3>Admin Menus</h3>

<hr size='1'><div class="admin_menu_item"><a href="admin_staticcontent.php">Page Content</a></div><div class="admin_menu_item"><a href="content_snippets.php">Content snippets</a></div><div class="admin_menu_item"><a href="client-useradmin.php">Manage Client Accounts</a></div><hr size='1'><div class="admin_menu_item"><a href="stats-net.php">Stats [net]</a></div><div class="admin_menu_item"><a href="stats.php">Stats [gross]</a></div><div class="admin_menu_item"><a href="ppc-links.php">Landing pages</a></div><div class="admin_menu_item"><a href="clean_leads.php">Cleanup Leads</a></div><div class="admin_menu_item"><a href="lookup.php">Lead Lookup</a></div><div class="admin_menu_item"><a href="data-export.php">Data Exports</a></div><hr size='1'><div class="admin_menu_item"><a href="clickheat/" target="_new">Click Heat</a> </div><div class="admin_menu_item"><a href="http://answers.clearonedebt.com/admin/" target="_new">Answers Admin</a> </div>

<hr size='1'>

<div class="admin_menu_item"><a href="userinfo.php?user=jcampanella">My Account</a></div>

<div class="admin_menu_item"><a href="useredit.php">Edit Account</a></div><div class="admin_menu_item"><a href="admin_users.php">Admin Center</a></div><hr size='1'>

<div class="admin_menu_item"><a href="process.php">Logout</a></div>

</div>

<script type="text/javascript">

function confirmDelete(url,msg) {

if(confirm(msg)==true){

  window.location.href = url;

}

}

</script>

<p />

<div class="admin_content">

Logged in as <b></b><br><br>

Back to [<a href="index.php">Main Page</a>]<br><br>

<table vlign="top"><tr><td>

  <table><tr><td><h1>Search Users</h1></td><td><h1>Register</h1></td></tr><tr vlign="top"><td><form action="Romeo.php" method="GET">

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

    <tr>

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

      <tr><td>Username:</td><td><input type="text" name="QUname" maxlength="30" value="rngo"></td></tr>

      <tr><td>FirstName:</td><td><input type="text" name="QFname" maxlength="30" value=""></td></tr>

            <tr><td>Last Name:</td><td><input type="text" name="QLname" maxlength="30" value=""></td></tr>

      <tr><td>Key Word:</td><td><input type="text" name="QKword" maxlength="30" value=""></td></tr>

      <tr><td>User Level:</td><td><input type="text" name="QUlevel" maxlength="2" value=""></td></tr></table>

</td>

    </tr>

  <tr><td align="center"><input type="submit" value="Search"></form></td></tr></table></td>

  <td align="left" vlign="top">

<form action="process.php" method="POST">

<table align="left" border="0" cellspacing="0" cellpadding="3"><tr><td>

<table align="left" border="0" cellspacing="0" cellpadding="3" vlign="top">

 

  <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value=""></td><td></td></tr>

  <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value=""></td><td></td></tr>

  <tr><td>Email:</td><td><input type="text" name="email" maxlength="50" value=""></td><td></td></tr>

</td></tr></table><tr><td align="center">

  <input type="hidden" name="subjoin" value="1">

  <input type="submit" value="Join!"></td></tr></form></table>

  </td></tr>

  </table>

<tr><td><table border="0" cellspacing="5" cellpadding="5">

<tr><td>

 

 

 

<table> <tr><td>User Name</td></tr><tr><td><form action="">

<select name="Uname">

<form action="adminprocess.php" method="POST">

Username:<br>

<select><option value='rngo11@clearonedebt.com'>rngo11@clearonedebt.com</option><option value='rngo1@clearonedebt.com'>rngo1@clearonedebt.com</option><option value='rngo@clearonedebt.com'>rngo@clearonedebt.com</option></select><input type="hidden" name="subdeluser" value="1">

<input type="submit" value="Delete User">

</form>

</td></tr></table></td></tr><tr><td>

 

 

</body>

</html>

 

 

 

Link to comment
Share on other sites

ok, well i can't see a problem with the dropdown, it looks like it should.

 

it is weird.  if i remove the <select> then the options will appear in the drop down.  if the <select> is there than it is out side the drop down.  however, i need the <select> for the name of the drop down to retrieve the selected value in the post back page.

 

Sorry I used to code with ASP.net, so i have this newbee question :).  btw, do you have a recommendation on which PHP text edit is best to use for PHP and MySQL?

Link to comment
Share on other sites

There is an error in your html:

<select name="Uname">

<form action="adminprocess.php" method="POST">

Username:

 

<select><option value='rngo11@clearonedebt.com'>rngo11@clearonedebt.com</option><option value='rngo1@clearonedebt.com'>rngo1@clearonedebt.com</option><option value='rngo@clearonedebt.com'>rngo@clearonedebt.com</option></select><input type="hidden" name="subdeluser" value="1">

<input type="submit" value="Delete User">

</form>

 

That tag is left open and is interfering, it should be within the form tag. You should remove it as your displayUsersDropDown function outputs the required html for the drop down.

Link to comment
Share on other sites

Wow sharp eyes.  I meant to put that in the dropdown function but forgot to delete i guess.  Thank you very much, that fixed the problem.

 

i have another newbee question,  if i want to retrieve the selected value from this dropdown on the adminprocess.php, do i use this,

 

$subuser = $_POST["deluser"]

where <select name="deluser"> ?

 

or is there anything else i have to do?

 

 

There is an error in your html:

<select name="Uname">

<form action="adminprocess.php" method="POST">

Username:

 

<select><option value='rngo11@clearonedebt.com'>rngo11@clearonedebt.com</option><option value='rngo1@clearonedebt.com'>rngo1@clearonedebt.com</option><option value='rngo@clearonedebt.com'>rngo@clearonedebt.com</option></select><input type="hidden" name="subdeluser" value="1">

<input type="submit" value="Delete User">

</form>

 

That tag is left open and is interfering, it should be within the form tag. You should remove it as your displayUsersDropDown function outputs the required html for the drop down.

Link to comment
Share on other sites

the selected value only.

 

Ok thank you so much.  I thought it's just like ASP.net where i have to give the control name and then choose the selected value.

 

Thank for your help. 

 

This goes to everybody as well. :)

 

You're probably see me on this forum more often [askign newbee questions :)] since i have to start coding PHP for this job. 

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.