avo Posted April 14, 2006 Share Posted April 14, 2006 HI All Wounder if you can help me solve this one please .what im doing is calling the db and retriving data from it and displaying it .This is the code bellow[code]if($_POST['subEdit']){ mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname); $sql = mysql_query("SELECT username ,name ,lname, waddress, pnumber, mnumber, email, ainfo, dateinfo FROM memlist WHERE username=buster"); } while($result = mysql_fetch_array($sql)) { $username = "" .$result["username"]; $name = "" .$result["name"]; $lname = "" .$result["lname"]; $waddress = "" .$result["waddress"]; $pnumber = "" .$result["pnumber"]; $mnumber = "" .$result["mnumber"]; $email = "" .$result["email"]; $ainfo = "" .$result["ainfo"]; $dateinfo = "" .$result["dateinfo"];[/code]But this bit of the code (buster )i would like it to point at a drop down box so when i select a user from the drop down this is then iserted into this section me clicking th button will then result in the code execution with the selected name from the dropdoown box.[code]busterdateinfo FROM memlist WHERE username=[quote]buster[/quote]"); [/code]my drop down table in HTML[code] </select> <select name="select"> <option>gavin</option> <option>buster</option> <option>mark</option> </select>[/code]Thanks in Advance Quote Link to comment Share on other sites More sharing options...
AV1611 Posted April 14, 2006 Share Posted April 14, 2006 I'm trying to understand your question:Are you trying to do a query, create a pulldown based on the result, then submit a second query based on what the user selects from the pulldown? Quote Link to comment Share on other sites More sharing options...
avo Posted April 14, 2006 Author Share Posted April 14, 2006 HI thanks for getting back to mewhat i have is a pull down list on my page ive added names to that list when i select one of them names i want that name to apper as ive i have typed it in the code (in place of buster)[code] $sql = mysql_query("SELECT username ,name ,lname, waddress, pnumber, mnumber, email, ainfo, dateinfo FROM memlist WHERE username=buster");[/code]then this will give me the results i need at the moment for example if i type the name buster in it will get the information i need from the db hope i explaned ok thanks again Quote Link to comment Share on other sites More sharing options...
avo Posted April 14, 2006 Author Share Posted April 14, 2006 Hi Can Anyone help me with this one please thanks. Quote Link to comment Share on other sites More sharing options...
jcbarr Posted April 14, 2006 Share Posted April 14, 2006 So what you want is the drop down box full of names on your page. When you select the name from the drop down you want it to display all their information that is in the database correct? If that is hat you want to do; try something like this;[code]if($_POST['subEdit']){ mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname); $user=$_POST['user']; $sql = mysql_query("SELECT username ,name ,lname, waddress, pnumber, mnumber, email, ainfo, dateinfo FROM memlist WHERE username='$user'"); while($result = mysql_fetch_array($sql)) { $username = $result['username']; $name = $result['name']; $lname = $result['lname']; $waddress = $result['waddress']; $pnumber = $result['pnumber']; $mnumber = $result['mnumber']; $email = $result['email']; $ainfo = $result['ainfo']; $dateinfo = $result['dateinfo']; } }[/code]Have your form do this;[code] <select name="user"> <option>gavin</option> <option>buster</option> <option>mark</option> </select>[/code]That should be a simple way to get what you want. Of course you will still have to format the output of the above script the way you want it, but that should be simple.If I'm not mistaken I don't believe you need all thos "" and . up there either when you are setting the variables. Quote Link to comment Share on other sites More sharing options...
avo Posted April 14, 2006 Author Share Posted April 14, 2006 HI Thankyou for that im sure i tryed that but must not have iv'e been on that now for a good 3 hours trying to figure out why..]Thankyou works great. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.