PHP - Working With Select Boxes
Hi There,
Is there any way that I can get a select box to auto-select the value from a SQL query? For example, if I have a select box like this: Dave,Jon,Simon,Fred And a select statement that brings back the value of Fred then the select box (in HTML) would: <select name='people'><option>Dave</option><option>Jon</option><option>Simon</option><option selected='selected'>Fred</option></select> Same as if the name was Dave, or Simon etc etc. Hope that makes sense? Cheers Matt Similar TutorialsHey guys,
My problem is, iam loading with mysql_fetch_array a table from my database and draw it into my website page.
The table is a user table which has an id, user, password and rights(Admin, Mod , User).
Only the rights are given out as <select> </select> boxes with the 3 options(Admin, Mod , User).
And i also have 1 more column which has for each row a href to a new site with the id of the array_index as paramter.
My Problem is i want to know which select box was changed and which option is selected so i can change the rights in my database of this user with the right id.
At the moment i cant post the code in here cause i have a problem with my laptop now.
I hope you can help me,
Thank you
Edited by Kandey, 30 October 2014 - 02:28 PM. Hi I am trying to have the following as an example: Code: [Select] <select name="test[]" multiple="multiple">options here</select> <select name="test[]" multiple="multiple">options here</select> Then using $_POST['test'] to grab the boxes in the array. I want to then loop over each box so for example: Code: [Select] $boxes = $_POST['test']; foreach ( $boxes as $box ) // now here i would of expected $box to be an array of the options, } but it's not working like this, all the options from all submitted select boxes come in one array so I cannot distinguish which select box in the array they relate to, is there a way to do this?? Brand new to the forum, and have only been working with HTML, PHP, & MySQL for about 3 months. I've run into an issue I can't seem to figure out how to work around. I want to have two select boxes, that are dependent on one another. For Example: First box lists types of games: RPG LARP Board Game Miniatures CCG The second box displays game names of the type selected above. I have a MySQL table setup for the second box. To be honest I kinda already have it working... with one small but MAJOR glitch. I select the first box and the page submits using onchange='this.form.submit()'. When the page reloads the first select box reverts back to it's default setting, but the second box does correctly filter & show the content based on the selection that was made in the first box. My Question: How do I set this up so that the first box displays the user selected setting while also passing the $_POST information to the second box? My Code: <table> <tr> <td width=50%> Game Type: </td> <td width=50%> <form name='game_type' action='event_submit.php' method='post'> <select name='game_type' align=center onchange='this.form.submit()' style="width:150px;margin:5px 0 5px 0;"> <option value=''>Chose a Game Type</option> <option value='RPG'>RPG</option> <option value='LARP'>LARP</option> <option value='Board Game'>Board Game</option> <option value='CCG'>Collectable Cards & Games</option> <option value='Miniatures'>Miniatures</option> </select> </form> </td> </tr> <tr> <td width=50%> Game System: </td> <td width=50%> <?php $game_type = $_POST['game_type']; echo "$game_type"; if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DrowCon", $con); $result = mysql_query("SELECT * FROM Games WHERE Type='$game_type' ORDER BY System ASC"); echo "<form name='game_system' action='event_submit_form.php' method='post'>"; echo "<select name='game_system' align=center style='width:150px;margin:5px 0 5px 0;'>"; echo "<option value=''>Chose a Game System</option>"; while($row_game = mysql_fetch_array($result)) { echo "<option value=''>".$row_game['System']."</option>"; } echo "</form>"; mysql_close($con); ?> </td> </tr> </table> Dear Support, Here is my code: <?php if ( strtolower($_SERVER['REQUEST_METHOD']) === 'post' ) { $name = isset($_POST['name]) ? htmlspecialchars($_POST['name']) : ""; $area = isset($_POST['area']) ? htmlspecialchars($_POST['area']) : ""; $choice = isset($_POST['choice ']) ? htmlspecialchars($_POST['choice ']) : ""; //Do Others } ?> <form class="customersForm" method="post"> <div class=""> <p>Name<br /> <select style="width:120px;" name="name"> <?php $sql = "select * from `name_info` order by `name`"; $query = mysql_query($sql); $dd = '<option>Name</option>'; while($row = mysql_fetch_object($query)) { $dd .= '<option>'.$row->name.'</option>'; } echo $dd; ?> </select> </p> </div> <div class=""> <p>Area<br /> <select style="width:120px;" area="area"> <?php $sql = "select * from `area_info` order by `area`"; $query = mysql_query($sql); $dd = '<option>Area</option>'; while($row = mysql_fetch_object($query)) { $dd .= '<option>'.$row->area.'</option>'; } echo $dd; ?> </select> </p> </div> <div class=""> <p>Choice<br /> <select style="width:120px;" choice="choice"> <?php $sql = "select * from `choice_info` where `name`='".$name."' and `area`='".$area."' order by `choice`"; $query = mysql_query($sql); $dd = '<option>Choice</option>'; while($row = mysql_fetch_object($query)) { $dd .= '<option>'.$row->choice.'</option>'; } echo $dd; ?> </select> </p> </div> ......//Others input fields ...some text fields ... </ form> I have the above code, where I would like to show the choice Drop-down box, depends on $name and $area match of the choice_info table. $name field and $area field needs to have any dependency and straight from the MySQL table. But, choice needs to depend on $name & $area. How can I do it without much using Javacript? I do not mind to use JavaScript, but prefer to minimal. By the way, I will have some other input fields too. It's an input form but, one drop-down box will be depends on two others choice. Thanks for your help. Hi, I had a form which contains, 8 select boxes. In those 8 select boxes, 3 of the boxes are interlinked, like, I am able to generate data in other 2 select boxes, if one box is been selected. i.e. based upon selection of one select box, and i am able to generate data in other select box. So, 3 select boxes are interlinked. And remaining 5 selects are optional, if the user selects, then we need to generate data based upon selection of the user. Here the main issue is how to grab data in the post back form, like, how to capture the number of selects boxes selected and what are those selected, and based upon that we need to generate data. Here one more important thing is that, in the report generation form(postback form), I need to show the data in a table. So , in table I had 9 columns and these would be common to whatever the selection made, but, only the requeired data would be changed based upon the selection of the remaining 5 optional boxes. Hope you got me!!!! Hello, I have the following function function make_agent_drop($dropname,$parent=''){ $agents = mysql_query("SELECT * FROM ad_category WHERE cat_status='1' AND parent_id='".(is_numeric($parent)?$parent:"0")."'") or die(mysql_error()); $anum = mysql_num_rows($agents); if($anum>0){ $agentdrop='<select style="width:150px; height:20px; margin-left:100px; font-size:11px;" name="'.$dropname.'" id="'.$dropname.'" class="text" '.(is_numeric($parent)?'':'onchange="update_subcatdrop($(this).val());').'"> <option value="0">Select a Category</option>'; while($row= mysql_fetch_array($agents)){ $agentdrop.='<option value="'.$row['cat_id'].'">'.$row['cat_name'].'</option>'; } $agentdrop.='</select>'; }else{ $agentdrop= 'No '.(is_numeric($parent)?'Sub':'').'Categories Found.'; } return $agentdrop; ; } I creates a drop down from database cats and sub cats.. I am trying to figure out how to add a submit button to dynamically appear when it displays the sub category... Thanks! Dan I need some help with the query for a form that selects values across multiple columns, and allow users to select multiple values in several columns. http://brinsterinc.com/tpa/tpasearch.php I assume you build the where clause for the sql by determining if there is an option value has been selected in the single-value select boxes. But how do I handle the multi-select list boxes? I'm desperate for help! Need to get somewhere with this over the weekend! TIA! Hello, I had 8 select boxes(dropdowns) in a form. Its like a search kind of implementation in the website. I don't know what the user selects, he may choose different select boxes, any number of select boxes. So, based upon the user selection, I need to generate the data. The data fields to be generated would be almost same. So, How would I know what the user selection is and how many select boxes has been selected and how could I generate different data based upon selected boxes. I had to make a small note abt this, that the data generation fields may change for some of the user select combinations, but most of the result fields would be same. so, can you please help me out, how to do, how to make different combination data generations, because, i had 8 fields, i had to make 8! combinations, that would result in a big code. I'm experimenting out premade codes and trying to make them some how work the way I want to. This is "my" image uploader. For the uploader is suppose to find the image AND the code stored in mysql, but it doesn't seem to find it. any problem? <?php $link = mysql_connect("localhost", "mcd", "whatanicepassword"); mysql_select_db("mcd", $link); if (!isset($_POST["code"])) { die ("Error: Not all fields complete"); } $limit_size=5120; $target = "skin/"; $target = $target . basename( $_FILES['uploaded']['name']); $ok=1; $filelol = $_FILES['uploaded']['name']; $file_size=$_FILES['uploaded']['size']; $filecheck = "skin/".$filelol; //This is our size condition if ($file_size >= $limit_size) { echo "Your file is too large.<br>"; $ok=0; } if (file_exists($filecheck)) { } else {echo $filelol." does not exist in the database. Please upload at the main site.<br>"; $ok=0;} // username and password sent from Form $uploaded=mysql_real_escape_string($_POST['uploaded']); $code=mysql_real_escape_string($_POST['code']); $checkquery = mysql_query("SELECT * FROM user_list WHERE uploaded = '$uploaded' AND code = '$code'") or die("Error : " . mysql_error()); $num_rows=mysql_num_rows($checkquery); if ($num_rows < 1 ) { echo 'File not found in MySQL<br><br><br>'; $ok=0; } else {echo 'YES!';} //This is our limit file type condition if (($_FILES["uploaded"]["type"] != "image/png")) { echo "You may only upload PNG files.<br>"; $ok=0; } if ($ok==0) { Echo "Sorry your file was not uploaded<br>"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ".$filelol." has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?> Hi, I am geting questions marks in place of some characters. However, this only happens on my own queries and echo statements, the same database read by wordpress handles them fine. Can anyone tell me why? I have added UTF-8 headers and meta tags, the database is in UTF-8 encoding. I just can't figure out why wordpress can manage it and my php cant. I have tried htmlentities with no luck the offending page: http://subverb.net the wordpress blog echoing out the exact same title from the same database http://nottingham.subverb.net/blog/sounddhism/ Thankyou Not really sure what to ask because I don't know what the problem is. Maybe just need a fresh set of eyes to find out whats wrong. I am trying selecting content from a database table but its not working. I am not getting any errors just a blank screen where the content should be displayed. html Code: [Select] <table> <tbody> <tr> <th>Topic</th> <th>Name</th> <th>Date</th> </tr> <?php include 'server/forum.php'; ?> </tbody> </table> php Code: [Select] <?php require_once('load_data.php'); $con = mysql_connect($db_host, $db_user, $db_pwd); if (!$con) { die('Could not connect to database: ' . mysql_error()); } $dbcon = mysql_select_db($database); if (!$dbcon) { die('Could not select database: ' . mysql_error()); } $sql = "SELECT * FROM $table ORDER BY id"; $result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); if (!$result) { die("Query to show fields from table failed:".mysql_error()); } $row = mysql_fetch_array($result) while($row) { echo '<tr>'; echo '<td class="forumtd"><b>'; echo '<a href="topic.php?id='.$row['id'].'">'.stripslashes(htmlspecialchars($row['topic'])).'</a>'; echo "</b></td>"; echo '<td class="forumtd"><em>'; echo stripslashes(htmlspecialchars($row['name'])); echo "</em></td>"; echo '<td class="forumtd">'; echo date("l M dS, Y", $row['date']); echo "</td>"; echo "</tr>"; } mysql_close($con); ?> Hi there, I'm having a problem with updating a record with an UPDATE mysql query and then following that query with a SELECT query to get those values just updated. This is what I'm trying to do...I'd like a member to be able to complete a recommended task and upon doing so, go to a page in their back office where they can check off that task as "Completed". This completed task would be recorded in their member record in our database so that when they return to this list, it will remain as "Completed". I'm providing the member with a submit button that will call the same page and then update depending on which task is clicked as complete. Here is my code: Code: [Select] $memberid = $_SESSION['member']; // Check if form has been submitted if(isset($_POST['task_done']) && $_POST['task_submit'] == 'submitted') { $taskvalue = $_POST['task_value']; $query = "UPDATE membertable SET $taskvalue = 'done' WHERE id = $memberid"; $result = mysqli_query($dbc, $query); } $query ="SELECT task1, task2, task3 FROM membertable WHERE id = $memberid"; $result = mysqli_query($dbc, $query); $row = mysqli_fetch_array($result, MYSQLI_ASSOC); $_SESSION['task1'] = $row['task1']; $_SESSION['task2'] = $row['task2']; $_SESSION['task3'] = $row['task3']; ?> <h4>Task List</h4> <table> <form action="" method="post"> <tr> <td>Task 1</td> <td><?php if($_SESSION['task1'] == 'done') {echo '<div>Completed</div>';} else{ echo '<input type="submit" name="task_done" value="Mark As Completed" />';} ?></td> </tr> <input type="hidden" name="task_value" value="task1" /> <input type="hidden" name="task_submit" value="submitted" /> </form> <form action="" method="post"> <tr> <td>Task 1</td> <td><?php if($_SESSION['task1'] == 'done') {echo '<div>Completed</div>';} else{ echo '<input type="submit" name="task_done" value="Mark As Completed" />';} ?></td> </tr> <input type="hidden" name="task_value" value="task2" /> <input type="hidden" name="task_submit" value="submitted" /> </form> <form action="" method="post"> <tr> <td>Task 1</td> <td><?php if($_SESSION['task1'] == 'done') {echo '<div>Completed</div>';} else{ echo '<input type="submit" name="task_done" value="Mark As Completed" />';} ?></td> </tr> <input type="hidden" name="task_value" value="task3" /> <input type="hidden" name="task_submit" value="submitted" /> </form> </table> The problem that I am having is that the database is not updated with the value "done" but after submission, the screen displays "Completed" instead of "Mark As Completed". So the value is being picked up as "done", but that is why I have the SELECT after the UPDATES, so that there is always a current value for whether a task is done or not. Then I refresh and the screen returns the button to Mark As Complete. Also, when I try marking all three tasks as, sometimes all three are updated, sometimes only one or two and again, I leave the page or refresh and the "Marked As Completed" buttons come back. Bizarre. If anyone can tell me where my logic is going wrong, I would appreciate it. I had this working, but when I try and get fancy and use AJAX the data doesn't display. I think this is a PHP problem though. My code for the select form including AJAX code Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB"> <head> <title>AJAX Example</title> <link rel="stylesheet" type="text/css" href="Form.css" media="screen" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("tr:odd").addClass("odd"); }); </script> <script type="text/javascript"> function showPlayers(str) { var xmlhttp; if (str=="") { document.getElementById("DataDisplay").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); else {// code for IE6, IE5 } xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("DataDisplay").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","Query.php?category_id="+str,true); xmlhttp.send(); } </script> </head> <body> <h1">AJAX Example</h1> <?php #connect to MySQL $conn = @mysql_connect( "localhost","username","pw") or die( "You did not successfully connect to the DB!" ); #select the specified database $rs = @mysql_SELECT_DB ("MyDB", $conn ) or die ( "Error connecting to the database test!"); ?> <form name="sports" id="sports"> <legend>Select a Sport</legend> <select name="category_id" onChange="showPlayers(this.value)"> <option value="">Select a Sport:</option> <?php $sql = "SELECT category_id, sport FROM sports ". "ORDER BY sport"; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { echo "<option value=\"".$row['category_id']."\">".$row['sport']."</option>\n "; } ?> </select> </form> <br /> <div id="DataDisplay"></div> </body> </html> Query.php <?php #get the id $id=$_GET["category_id"]; #connect to MySQL $conn = @mysql_connect( "localhost","username","pw") or die( "Error connecting to MySQL" ); #select the specified database $rs = @mysql_SELECT_DB ("MyDB", $conn ) or die ( "Could not select that particular Database"); #$id="category_id"; #create the query $sql ="SELECT * FROM sports INNER JOIN players ON sports.category_id = players.category_id WHERE players.category_id = '".$id."'"; echo $sql; #execute the query $rs = mysql_query($sql,$conn); #start the table code echo "<table><tr><th>Category ID</th><th>Sport</th><th>First Name</th><th>Last Name</th></tr>"; #write the data while( $row = mysql_fetch_array( $rs) ) { echo ("<tr><td>"); echo ($row["category_id"] ); echo ("</td>"); echo ("<td>"); echo ($row["sport"]); echo ("</td>"); echo ("<td>"); echo ($row["first_name"]); echo ("</td>"); echo ("<td>"); echo ($row["last_name"]); echo ("</td></tr>"); } echo "</tr></table>"; mysql_close($conn); ?> I think the problem is either with this part in the AJAX Code: [Select] xmlhttp.open("GET","Query.php?category_id="+str,true); or most likely in my Query.php code when I wasn't using AJAX and using POST it worked fine, but adding the AJAX stuff and GET it doesn't work. When I echo out the SQL the result is Code: [Select] SELECT * FROM sports INNER JOIN players ON sports.category_id = players.category_id WHERE players.category_id = '' so the category_id is not being selected properly and that is the primary key/foreign key in the MySQL table which connects the JOIN. hirealimo.com.au/code1.php this works as i want it: Quote SELECT * FROM price INNER JOIN vehicle USING (vehicleID) WHERE vehicle.passengers >= 1 AND price.townID = 1 AND price.eventID = 1 but apparelty selecting * is not a good thing???? but if I do this: Quote SELECT priceID, price FROM price INNER JOIN vehicle....etc it works but i lose the info from the vehicle table. but how do i make this work: Quote SELECT priceID, price, type, description, passengers FROM price INNER JOIN vehicle....etc so that i am specifiying which colums from which tables to query?? thanks I have 2 queries that I want to join together to make one row
Dear All, I wish to have 2 drop down boxes, Country Select Box and Locality Select Box. The locality select box will be affected by the value chosen in the country select box. All is working fine except that the locality select box is not being populated. I know that the problem is in the sql statement WHERE country_id='$co' because i am having an error that $co is an undefined variable. All the rest works fine because i have replaced the $co variable directly with a number (say 98) for a particular country id and it worked fine. In what way can i define this variable $co so that it is accepted by my sql statement? Thank you for your help in advance. MySQL Tables indicated below: CREATE TABLE countries( country_id INT(3) UNSIGNED NOT NULL AUTO_INCREMENT, country_name VARCHAR(30) NOT NULL, PRIMARY KEY(country_id), UNIQUE KEY(country_name), INDEX(country_id), INDEX(country_name)) ENGINE=MyISAM; CREATE TABLE localities( locality_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, country_id INT(3) UNSIGNED NOT NULL, locality_name VARCHAR(50), PRIMARY KEY (locality_id), INDEX (country_id), INDEX (locality_name)) ENGINE=MyISAM; Extract PHP script included below: // connect to database require_once(MYSQL); if(isset($_POST['submitted'])) { // trim the incoming data /* this line runs every element in $_POST through the trim() function, and assigns the returned result to the new $trimmed array */ $trimmed=array_map('trim',$_POST); // clean the data $co=mysqli_real_escape_string($dbc,$trimmed['country']); $lc=mysqli_real_escape_string($dbc,$trimmed['locality']); } ?> <form action="form.php" method="post"> <p>Country <select name="country"> <option>Select Country</option> <?php $q="SELECT country_id, country_name FROM countries"; $r=mysqli_query($dbc,$q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); while($row=mysqli_fetch_array($r)) { $country_id=$row[0]; $country_name=$row[1]; echo '<option value="' . $country_id . '"'; if(isset($trimmed['country']) && ($trimmed['country']==$country_id)) echo 'selected="selected"'; echo '>' . $country_name . '</option>\n'; } ?> </select> </p> <p>Locality <select name="locality"> <option>Select Locality</option> <?php $ql="SELECT locality_id, country_id, locality_name FROM localities WHERE country_id='$co' ORDER BY locality_name"; $rl=mysqli_query($dbc,$ql) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); while($row=mysqli_fetch_array($rl)) { $locality_id=$row[0]; $country_id=$row[1]; $locality_name=$row[2]; echo '<option value="' . $locality_id . '"'; if(isset($trimmed['locality']) && ($trimmed['locality']==$locality_id)) echo 'selected="selected"'; echo '>' . $locality_name . '</option>\n'; } // close database connection mysqli_close($dbc); ?> </select> </p> <p><input type="submit" name="submit" value="Submit" /></p> <input type="hidden" name="submitted" value="TRUE" /> </form> Im having a problem in popup box.. i made a checkbox in a loop.. then after a success loop ive set a code for a popupbox. Code: [Select] echo '<script type="text/javascript"> {alert("Rejected!");} </script>'; But when a user checked 2 check boxes.. it would also popup a 2 popup box.. How can i make my code only popup once even if it selects multiple checkboxes? Hi I have 3 drop down boxes and I want my boxes to go to another page when I select them and click go. For example if I click western cape I want it to give me all the resorts in western cape and if I click western cape and beaches I want it to give me all the resorts that are in the western cape that are next to beaches. I have been able to populate the drop down boxes with information and it can go to another page but it doesn't give me the information I want. This is my drop down boxes code Code: [Select] <script type="text/javascript"> function showGo(){ var region_id = $("#region_id").val(); var lifestyle_id = $("#lifestyle_id").val(); var resort_facility_id = $("#resort_facility_id").val(); if((region_id != 'false') || (lifestyle_id != 'false') || (resort_facility_id != 'false')){ $("#destinationSearchButton").css('display', 'block'); }else{ $("#destinationSearchButton").css('display', 'none'); } </script> <form action="/pages/search/" method="post"> <select class="formSelect" name="region_id" id="region_id" size="1" tabindex="1" onchange="showGo()"> <option label="Region"> <?php $regions_model = new regions_model('regions'); $regions = $regions_model -> get_all(); foreach($regions as $region){ $name = $region['name']; $id =$region['id']; $select = "SELECT $id, $name FROM regions"; echo "<option value='$id'>$name</option>"; } ?> </option> </select> <select class="formSelect" name="lifestyle_id" id="lifestyle_id" size="1" tabindex="2" onchange="showGo()"> <option label="lifestyle"> <?php $lifestyles_model = new lifestyles_model('lifestyles'); $lifestyles = $lifestyles_model -> get_all(); foreach($lifestyles as $lifestyle){ $name = $lifestyle['name']; $id = $lifestyle['id']; $select = "SELECT $name FROM lifestyles"; echo "<option name='$id'>$name</option>"; } ?> </option> </select> <select class="formSelect" name="resort_facility_id" id="resort_facility_id" size="1" tabindex="3" onchange="showGo()"> <option label="Facilities & Amenities"> <?php $resort_facilities_model = new resort_facilities_model('resort_facilities'); $resort_facilities= $resort_facilities_model -> get_all(); foreach($resort_facilities as $resort_facility){ $name = $resort_facility['name']; $id = $resort_facility['id']; $select = "SELECT $name FROM resort_failities"; echo "<option name='$id'>$name</option>"; } ?> </option> </select> <input class="formInputButton" type="submit" name="submitButtonName" id="destinationSearchButton" value="Go" tabindex="4"/ style="display: none;" /> </form> </div> Thank you Hi all Im looking to do a "SIMPLE" search on a databse usign php. I want to have a drop down box like so : <select name="Lowest"> <option>0</option> <option>100</option> <option>200</option> </select> this is for the prices i want 2 of these so that the first will be the lowest price and the second will be the higher price Then i will make a query to SELECT * WHERE ( i dont know how to call the results from the select box here to display the whole tabled results ) any help please thnax Hi, im new to php and got a simple query. i have built a web gallery and i want to add keywords to pictures, ive built the interface and mysql statements so it lists all possible keywords and creates a tick box for the user to use. ive created a table to join the image id's to my keyword id's as its going to be a many to many relationship, ive also built the sql statement below to select the highlighted image, but im not sure how i can join the looping of all keywords to generate the tick boxes and then to loop again to populate the tickboxes that are saved within the DB - if that makes sense?? SELECT * FROM images,img_key,keywords where img_key.img_id=images.id and keywords.id=img_key.key_id and images.id='2' |