I want to enter data into my mysql db but into a specific row, when the user enters a number and clicks a button. For example, if the user logged in, is called 'user', then the data which is entered will go into a column called 'ticket' which is in the same row as the username 'user'.
I have written the code for it to go into the db but in a new row:
Code for page which user enters the data:
<?php require('check.php')?>
<html>
<head>
<title><?php echo $row['username']; ?> Profile</title>
</head>
<body>
<p style="float: right"><a href="logout.php">LOG OUT</a></p>
<?php
include ('connect.php');
$user_id= $_SESSION['id'];
$sql = "SELECT username FROM user WHERE user_id = '$user_id'";
$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
$uname = mysql_fetch_array($result);
$user_id= $_SESSION['id'];
$sql = "SELECT email FROM user WHERE user_id = '$user_id'";
$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
$uemail = mysql_fetch_array($result);
echo "Hello" . " " . $uname['username'];
?>
<h1>Choose ticket Amount</h1>
<hr />
<form method="post" action="addticket.php">
<label for="elliegoulding">Ellie Goulding Ticket Amount: </label>
<input type="text" name="elliegoulding" max="3" maxlength="3" /><br />
<br />
<input type="submit" value="Add ticket"/>
<br />
<hr />
<div id="footer">
</div>
</form>
</body>
</html>
Code for php page which processes information and adds to db:
<?php
$elliegoulding = $_REQUEST["elliegoulding"];
$linkme = mysql_connect("mysql.cms.gre.ac.uk","ta210","*****");
if (!$linkme)
die ("Could not connect to database");
mysql_select_db("mdb_ta210", $linkme);
$query = "INSERT INTO user (ticket) VALUES ('$elliegoulding, Ellie Goulding Tickets')";
mysql_query ($query, $linkme)
or die ("Ticket purchase failed.");
echo ("You have just bought $elliegoulding Ellie Goulding tickets");
mysql_close($linkme);
?>
Like I said the above code works and enters it into the database but just into a new row. Any help or suggestions would be great.