ok so here is my code:
<html>
<body>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_DB", $con);
//Get all the data from the table
$result = mysql_query("SELECT * FROM Vehicles")
or die(mysql_error());
echo "<table border = '1'>";
echo "<tr><th>ID</th><th>Year</th><th>Make</th><th>Model</th>
<th>Milage</th><th>Description</th></tr>";
//keeps getting the next row untill no more exist
while($row = mysql_fetch_array($result))
{
//print out the contents of each row
echo "<tr><td>";
echo $row['id'];
echo "</td><td>";
echo $row['year'];
echo "</td><td>";
echo $row['make'];
echo "</td><td>";
echo $row['model'];
echo "</td><td>";
echo $row['mileage'];
echo "</td><td>";
echo $row['description'];
echo "</td></tr>";
}
echo "</table>";
?>
<form action="upload.php" method="post"
enctype="multipart/form-data">
<input type="text" name="refID" value=<?php echo $ref ?> />
<label for="file">Upload Picture:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
what I need to do is pass the value of $row['id'] to my upload.php code which is as follows:
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_DB", $con);
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("VPics/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"VPics/" . $_FILES["file"]["name"]);
echo "Stored in: " . "VPics/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
I need to pass the information over so I can insert it into a table to keep track of the uploads properly