Jump to content

Add data to table


slj90

Recommended Posts

Hello,

 

What would be the easiest way to enter the word 'Pistol' into my mysql table when the user presses a button?

 

I came up with the following code as a guide to show you, however its coded incorrectly as i'm new to this..

 

<?php
include ("connectionusers.php");

$ID = $_SESSION["authenticatedUser"] ;
  
$ID = $_GET['ID'] ;

$query = "INSERT INTO users WHERE ID = $ID (Weapon1) VALUES ('Pistol')";

$result = mysql_query ($query);
?>

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/188546-add-data-to-table/
Share on other sites

If you are insert a data you can try this...

 

<?php
include ("connectionusers.php");

$ID = $_SESSION["authenticatedUser"] ;
  
$ID = $_GET['ID'] ;

$query = "INSERT INTO `users`(`Weapon1`) VALUES (\"Pistol\")";

$result = mysql_query ($query);
?>

 

or

 

Updating a data.

 

<?php
include ("connectionusers.php");

$ID = $_SESSION["authenticatedUser"] ;
  
$ID = $_GET['ID'] ;

$query = "UDPATE `users` SET `Weapon1` = \"Pistol\" WHERE `ID` = \"${ID}\"";

$result = mysql_query ($query);
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/188546-add-data-to-table/#findComment-995425
Share on other sites

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.