Hi,
How would you insert a picture uploaded to an already existing row? I tried using the WHERE clause with the INSERT statement, but it didn't work. Here is the whole code I'm using:
<?php
include "db_connect.php";
$sql = 'SELECT * FROM `Member` LIMIT 0, 30 ';
$result = mysql_query($sql);
while ($row=mysql_fetch_array($result))
{
$username=$row["loginName"];
}
?>
<html>
<head>
<title>Upload Pictures</title>
</head><body>
<form action="upload.php" method="post" enctype="multipart/form-data">
<tr>
<td height='24'><font size='2' face='verdana'>Picture</font></td>
<td><font size='2' face='verdana'>
<input name='Picture' type='file' id='picture' /> </font></td>
</tr>
<tr>
<td height='24'><font size='2' face='verdana'></font></td>
<td><font size='2' face='verdana'>
<input type="submit" name="submit"> </font></td>
</tr>
</form>
<?php echo "Now Uploading: $username<BR><BR>";?>
<?php
if ($submit)
{
If($Picture != "none") {
$PSize = filesize($Picture);
$mysqlPicture = addslashes(fread(fopen($Picture, "r"), $PSize));
include "db_connect.php";
mysql_query("INSERT INTO Member (Image) VALUES ('$mysqlPicture') WHERE loginName=$username") or die("Can't Perform Query");
echo "Your picture was uploaded.";
}
else {
echo "You did not upload any picture";
}
}
?>
</body>
</html>
Here is what the structure for the table looks like:
loginName createDate password firstName lastName email Image