Jump to content

[SOLVED] Just a quickie! :) 1 minute read and solve


futurewii

Recommended Posts

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

Sorry it wasnt explained well :P 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"

<?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?

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.