Jump to content

Nublette

New Members
  • Posts

    2
  • Joined

  • Last visited

Nublette's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, Thanks for the reply, I know my code is bad, I am just trying to get it functional before I start to work on making it more efficient, I will design the tables and code better and repost, hopefully I will get what I need then, thanks for the post I appreciate it, it has made me aware that I need my code and table design in a much better condition before I ask for help. I was aware that I am terrible at this but you have made it even more keenly felt, to be honest I kind of just want to uninstall windows and go cry in a corner.
  2. Hey there, Hoping someone can help me. I am trying to create a page on a wordpress site that will enable users to select 4 seperate fields from 4 drop down lists, hit a submit button and then be presented with search results from a MYSQL query based on their selections from the drop down list. I am a complete noob at php and MYSQL having not touched either since Uni. Please help out if you can. Here is the code. I have omitted the database connection details for obvious reasons. //Select City from Users table $queryCity = "SELECT City FROM Users"; $resultCity = mysql_query($queryCity) or die(mysql_error()); //Select AO from Users table $queryAO = "SELECT AO FROM Users"; $resultAO = mysql_query($queryAO) or die(mysql_error()); //Select Job from Users table $queryJob = "SELECT Job FROM Users"; $resultJob = mysql_query($queryJob) or die(mysql_error()); //Select Skills from Users table $querySkills = "SELECT Skills FROM Users"; $resultSkills = mysql_query($querySkills) or die(mysql_error()); //Create City dropdown list object $dropdownCity = "<select name='selectCity'>"; while($rowCity = mysql_fetch_assoc($resultCity)) { $dropdownCity .= "\r\n<option value='{$rowCity['City']}'>{$rowCity['City']}</option>"; } $dropdownCity .= "\r\n</select>"; //Create AO dropdown list object $dropdownAO = "<select name='selectAO'>"; while($rowAO = mysql_fetch_assoc($resultAO)) { $dropdownAO .= "\r\n<option value='{$rowAO['AO']}'>{$rowAO['AO']}</option>"; } $dropdownAO .= "\r\n</select>"; //Create Job dropdown list object $dropdownJob = "<select name='selectJob'>"; while($rowJob = mysql_fetch_assoc($resultJob)) { $dropdownJob .= "\r\n<option value='{$rowJob['Job']}'>{$rowJob['Job']}</option>"; } $dropdownJob .= "\r\n</select>"; //Create Skills dropdown list object $dropdownSkills = "<select name='selectSkills'>"; while($rowSkills = mysql_fetch_assoc($resultSkills)) { $dropdownSkills .= "\r\n<option value='{$rowSkills['Skills']}'>{$rowSkills['Skills']}</option>"; } $dropdownSkills .= "\r\n</select>"; //Print the drop downlists on the page echo "Please choose from the following fields below:"; echo "Location &nbsp&nbsp&nbsp"; echo $dropdownCity; echo "AO Level &nbsp&nbsp&nbsp"; echo $dropdownAO; echo "Occupation &nbsp&nbsp&nbsp"; echo $dropdownJob; echo "Skills &nbsp&nbsp&nbsp"; echo $dropdownSkills; ?> <form method="post" action="mypage.php"> <input type="submit" value="submit" name="Submit"> <?php //This code is for retrieving the results of the drop down selections after the submit button is clicked $selectionCity = $_POST["selectSkills"]; $selectionJob = $_POST["selectJob"]; //SQL query from retrieved results //SQL query from retrieved results $sqlresults = "SELECT * FROM Users WHERE City='"$selectionCity"' AND Job='"$selectionJob"'"; $sqlpost = mysql_query($sqlresults) or die(mysql_error()); echo $sqlpost; ?> I know the page looks horrible, trying to tackle one issue at a time and get this functional. Thanks for any and all help.
×
×
  • 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.