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 Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/ 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? =/ Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565221 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" Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565224 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? =/ Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565227 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? Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565230 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? Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565232 Share on other sites More sharing options...
futurewii Posted June 13, 2008 Author Share Posted June 13, 2008 Thanks a bazillion Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565233 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. Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565235 Share on other sites More sharing options...
futurewii Posted June 13, 2008 Author Share Posted June 13, 2008 haha ok Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565239 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 Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565240 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. Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565241 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 Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565243 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. Link to comment https://forums.phpfreaks.com/topic/110141-solved-just-a-quickie-1-minute-read-and-solve/#findComment-565245 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.