Jump to content

adding rows


tet3828

Recommended Posts

I am trying to use this code to add values to a drop down menu. I can tell the variable is being passed to the correct document(PHP_SELF) however the value will not store into the mysql table. is my syntax incorrect?

I've read and copied and pasted several samples of scrips attempting the same task but they are causing parse errors.

 

$fields = mysql_list_fields("21support", "apps", $connection); 

$columns = mysql_num_fields($fields); 

echo "<form action=page_to_post_to.php method=POST><select name=Field>"; 

for ($i = 0; $i < $columns; $i++) { 

    echo "<option value=$i>"; 

    echo mysql_field_name($fields, $i); 

    } 

echo "</select></form>"; 

echo "<br/>";

echo "Add Software";

 

if(isset($_POST[software]));

 

$newapp = $_POST[software];

$add_app =  " INSERT INTO `apps` ( `$newapp` VALUES (NULL , '$title');";

mysql_query($add_spp);

 

?>

Link to comment
Share on other sites

okay Im closer now, thank you.

 

but my original syntax inserting the form data was incorrect. The SQL table 'apps' only contains one column and X amount of rows. SO rather than adding  a new row with multiple columns I just need to add one new row.

 

That would leave me to believe this syntax would work but it give me a funky error:

 

Error in INSERT INTO `apps` VALUES ('') Column count doesn't match value count at row 1

Which makes no sense to me because I don't want to add columns just rows.

$newapp = $_POST[software];

$add_app =  " INSERT INTO `apps`  VALUES ('$newapp') ";

???

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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