shruti Posted August 1, 2008 Share Posted August 1, 2008 I want to have a list box with values coming from a column of table "XYZ" When someone clicks one value , on the side it shows the other fields of the table "XYZ" Can someone show me to a simple example as to how should i go about doing this? Quote Link to comment Share on other sites More sharing options...
.josh Posted August 1, 2008 Share Posted August 1, 2008 You would do that with ajax. There are a million million billion examples of doing "dynamic dropdown" boxes. Google ftw. Quote Link to comment Share on other sites More sharing options...
shruti Posted August 1, 2008 Author Share Posted August 1, 2008 You are misunderstanding me I have a listbox, and if you click on one value"say XXX" in it then it will display( select * from table where value='xxx') I tired but i am getting an error Quote Link to comment Share on other sites More sharing options...
.josh Posted August 1, 2008 Share Posted August 1, 2008 No I understood you, you want a dynamic dropdown. Show your code and what the error is. It may possibly be a problem with your php getting the data or it may be a problem with your javascript, idk, need more info. Quote Link to comment Share on other sites More sharing options...
shruti Posted August 1, 2008 Author Share Posted August 1, 2008 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <form id="form1" name="form1" method="get" action="<? echo $PHP_SELF; ?> "> <?php $host = "localhost"; $user = $pass = $dbname = $connection = mysql_connect("localhost", "root", "") or die("Cannot connect to MySQL server: " . mysql_error()); $db_selected = mysql_select_db(' ' , $connection); $query ="select CELLID from comments"; $result=mysql_query($query); echo "<select name='CELLID'>\n"; while($row=mysql_fetch_assoc($result)){ echo "<option value=\"$row[CELLID]\">$row[CELLID]</option>\n"; } echo "</select>"; ?> <input type="submit" name="Submit" value="Select" /> </form> <hr> <p> <? if (isset($_GET['submit'])){ $result=mysql_query("select problem, solution from comments where id='$select'"); while($row_list=mysql_fetch_assoc($result){ echo $row['problem']; // End if statement. } // Close database connection. mysql_close(); ?> </p> </body> </html> Quote Link to comment Share on other sites More sharing options...
shruti Posted August 1, 2008 Author Share Posted August 1, 2008 It gets the cellids from the table but on submit it does not display the related data on the bottom of the page. Please help Quote Link to comment Share on other sites More sharing options...
shruti Posted August 1, 2008 Author Share Posted August 1, 2008 y no one is helping??????????? Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 1, 2008 Share Posted August 1, 2008 Because you can get this on google. It's just like a dynamic dropdown. If it's not exactly what you want/need, adapt a dropdown code. If you can get to where you are now, you can easily adapt an AJAX code. Quote Link to comment Share on other sites More sharing options...
shruti Posted August 1, 2008 Author Share Posted August 1, 2008 i thought these forums where to help people stuck with something............... if you know so much then y dont u just find my error. huuuuhhhhhhhhhh!! What a mistake joining this forum Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 1, 2008 Share Posted August 1, 2008 It's a help forum. You're not paying us, we have nothing telling us to help you. Manners and courtesy are a huge motivation, for the reference. Why should we write your code for you? We've told you where to look, and there's nothing stopping you looking there. We're not here to work for you, we're here to help you. Like you said, we help people 'stuck with something'. We offered you a rope, and you didn't grab it. Quote Link to comment Share on other sites More sharing options...
shruti Posted August 1, 2008 Author Share Posted August 1, 2008 I understand, I know where to look. But sometimes when you hand a snake (looks like a rope) to a baby (who does not know as much as you do) you need to explain when to play with a rope and when not to touch something like a snake. Anyways................there are others who help with a small change in my code. Good bye Quote Link to comment Share on other sites More sharing options...
.josh Posted August 1, 2008 Share Posted August 1, 2008 Look man, you asked for help on a very common thing, which suggests you didn't bother to even search. Then you flat out admit that you're trying to get someone to do it for you instead of search. I asked you to post code and errors. You posted some code yes, but you didn't tell us what's wrong. We aren't psychic. We don't know what your code is supposed to be doing in the context of the rest of your site, blahblahblah long story short, you need to help us in order for us to help you, and just posting something and saying "fix it" and acting like it's our "duty" to do it, is not our idea of you helping. At the end of the day, it's your problem, not ours, so getting an attitude about it only hurts you. 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.