futurewii Posted June 13, 2008 Share Posted June 13, 2008 Hello, I have a form on one page (create.php) which sends the data to a process file (processcreate.php). One of the options on create.php is a drop down box which allows the user to choose a game console from a list of things like Nintendo Wii, Xbox 360 etc. the values are all assigned to 3 digit references (Xbox 360 = 360, Nintendo Wii = wii, etc.) i have a database in MySql for entries for each console. How do i edit the process file so that the INSERT INTO <database> changes depending on what value was chosen in the form? query = "INSERT INTO "console" reviews thats what the insert into looks like $console = $_POST["console"]; thats the process file picking up the selection (it works, just doesnt insert into databse depenidng on selection) <tr><td class="style8"> <p class="style8"><span class="style9">Console of Game:</span><br><select name="console"> <option value ="wii">Nintendo Wii</option> <option value ="nds">Nintendo DS</option> <option value ="ngc">Gamecube</option> <option value ="360">Xbox 360</option> <option value ="xbx">Xbox</option> <option value ="ps3">Playstation 3</option> <option value ="ps2">Playstation 2</option> <option value ="ps1">Playstation</option> <option value ="psp">Sony PSP</option> <option value ="ret">Retro Console</option> <option value ="oth">Other Console</option> </select><span class="style9"> </span> </tr></td> theres the drop down box code help MUCH appreciated Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 *Head implodes* I really which that you'd give more information. Do you want it in to change tables, or do you want it to be put in a consoles column, or what? =/ Quote Link to comment Share on other sites More sharing options...
futurewii Posted June 13, 2008 Author Share Posted June 13, 2008 Sorry it wasnt explained well Ill put it like this... If someone chooses Xbox 360 from the drop down menu, i want the form to post it into a table (pre created) called "360reviews" But if someone chooses Nintendo Wii from the drop down menu, i want the form to post it into a table called "wiireviews" Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 $console = $_POST['console']; $table = $console . "review"; Then use $table as your tablename. Also, why are you using HTML tables for layouts? =/ Quote Link to comment Share on other sites More sharing options...
futurewii Posted June 13, 2008 Author Share Posted June 13, 2008 to make it look tidy Thanks a million.. so im i right in putting "INSERT INTO $table (title, re... that? Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 13, 2008 Share Posted June 13, 2008 <?php $_handle=mysql_connect("host","username","password"); $_db=mysql_select_db("database",$_handle); mysql_query("INSTERT INTO ".$_POST["console"]."reviews (review) VALUES ('User submitted review here')"); mysql_close($_handle); ?> Something like that? Quote Link to comment Share on other sites More sharing options...
futurewii Posted June 13, 2008 Author Share Posted June 13, 2008 Thanks a bazillion Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 to make it look tidy Thanks a million.. so im i right in putting "INSERT INTO $table (title, re... that? Yeah, just like that. And learn CSS. You'll appreciate that advice later on. Quote Link to comment Share on other sites More sharing options...
futurewii Posted June 13, 2008 Author Share Posted June 13, 2008 haha ok Quote Link to comment Share on other sites More sharing options...
futurewii Posted June 13, 2008 Author Share Posted June 13, 2008 im getting the message.. "Unknown column 'console' in 'field list" now sorry to be such a begging n00b <?php include "includes/conn.php"; $title = $_POST["title"]; $review = $_POST["review"]; $console = $_POST["console"]; $image = $_POST["image"]; $user = $_POST["user"]; $table = $console . "reviews"; $query = "INSERT INTO $table (title, review, console, image, user)VALUES('$title','$review','$console','$image','$user')"; can anyone tell me what php is bitching about now? ??? thanks Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 PHP isn't bitching about anything...you don't have a console column in the database. Quote Link to comment Share on other sites More sharing options...
futurewii Posted June 13, 2008 Author Share Posted June 13, 2008 crap forgot i took it out.. now i feel embarrased :'( thanks anyway Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 Any time. =) Please click "Solved" in the bottom-left when you get a chance. 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.