This code is working for me…Now Based on the selection of this can the information be displayed?..I am on the process of writting the code…Plz do guide if I encounter any problem…Thanks for the support…
For example i have information stored in database about color…Now on selection of colors from dropdownlist how those info will be displayed in another page or form?
ok…To be more precise or clear…I have description about each color that is stored in database…If I want to display that information i.e when I select particular color and submit it how can the information stored in database be displayed?
thats true…But do I need to write sql code for each color?
$sql = "SELECT colorinfo FROM colours WHERE Color = ‘black’ ";
this would display the info abt black…what if I needed info about blue?.I should manually go back to code and make the changes…Is there any other way out?
Yes, when you submit the form, take the value of the colour selection from the drop-down list, use that in the query to retrieve the information, and then display it.
It wouldn’t be any different than your INSERT statement that takes the value from the form and puts in the INSERT statement to insert into the database. You have the value the user selected, put that in your WHERE clause.
Very roughly, but based on your own code from further up
if (isset($_POST['Colors'])) {
$cl = $_POST['Colors'];
$query = "Select * from colours where colors = '$cl'";
if (! $res=mysql_query($query, $con)) {
die("Error");
}
$row = mysql_fetch_assoc($res);
echo $row['shade'];
}
Check and double-check your column, table and variable names and if this is a new database, think about them - just in typing seven or eight lines there we’ve got “Colors” and “colours” and it just gets confusing.
Also I’m not 100% sure about retrieving the data using the no-longer-supported mysql calls, so there might be some syntax issues there. You need to move to something else, especially if this is new code or you’re learning - it’s a waste of time learning how to use code that is no longer part of the language.