But if you store them as files in the ftp, how do you allow users to upload pictures to be used with information that they submit which is stored in and called from the database?
I'm working on something that allows users to submit bios on their favorite comic book characters. I'd like a way to allow users to submit an image of this character, and have it displayed with the information on that character. And since the script I'm using pulls the info from the database, I'm hoping to figure out a way to allow users to send the pics to the db and retrieve them in the same fashion as the text.
Here's the script I'm using to list the characters and it also shows each character's bio when you choose one....
<html>
<body background="http://www.neropolis.com/vb/images/background.gif" TEXT="#000000" LINK="#0000FF" VLINK="#000000">
<table align="center" border="0">
<tr><td align="center">
<img src="/images/cbdimage.gif">
</td></tr>
<tr>
<td align="center"><a href="/cbd/submitbio.php"><b>Submit a Character bio</b></a> | <a href="/cbd/bioslist.php"><b>Back to Character Index</b></a></td>
</tr>
<tr><td>
<table border="0">
<tr><td>
<?php
$db = @mysql_connect('localhost', '*******', '**********')
or die("Could not connect: " . mysql_error());
mysql_select_db("**********", $db);
// display individual record
if ($id)
{
$result = mysql_query("SELECT * FROM cbd WHERE id=$id", $db);
$myrow = mysql_fetch_array($result);
printf("<b>Company:</b> %s\n<br>", $myrow['company']);
printf("<b>Name:</b> %s\n<br>", $myrow['name']);
printf("<b>Real Name:</b> %s\n<br>", $myrow['realname']);
printf("<b>First Appearance:</b> %s\n<br>", $myrow['firstappearance']);
printf("<b>Group Affiliation:</b> %s\n<br>", $myrow['team']);
printf("<b>Height:</b> %s\n<br>", $myrow['height']);
printf("<b>Weight:</b> %s\n<br>", $myrow['weight']);
printf("<b>Hair Color:</b> %s\n<br>", $myrow['hair']);
printf("<b>Eye Color:</b> %s\n<br><br>", $myrow['eyes']);
printf("<b>Powers and Abilities:</b> %s\n<br><br>", $myrow['powers']);
printf("<b>Known Weaknesses:</b> %s\n<br><br>", $myrow['weakness']);
printf("<b>History:</b> %s\n<br>", $myrow['history']);
// single quotes marks array pointers
}
else
{
// show character list
$result = mysql_query("SELECT * FROM `cbd` ORDER BY `name` ASC", $db);
if ($myrow = mysql_fetch_array($result))
{
// display list if there are records to display
do
{
// printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow['id'], $myrow['company'], $myrow['name']);
echo "<a href='$PHP_SELF?id=" . $myrow['id'] . "'>". $myrow['name'] . " \n<br />";
}
while ($myrow = mysql_fetch_array($result));
}
else
{
// no records to display
echo 'Sorry, no records were found!';
// single quotes are best to use when theres no variables in the echo.
}
}
?>
</td></tr>
</table>
</td></tr>
</table>
</body>
</html>
And here's the submission form I'm using...
<html>
<body background="http://www.neropolis.com/vb/images/background.gif" TEXT="#000000" LINK="#0000FF" VLINK="#000000">
<table align="center" border="0">
<form method="post" action="<?php echo $PHP_SELF?>">
<tr>
<td colspan="2" align="center"><img src=/images/submit.gif></td>
<tr>
<td align="center" colspan="2"><a href="/cbd/submitbio.php"><b>Submit a Character bio</b></a> | <a href="/cbd/bioslist.php"><b>Back to Character Index</b></a></td>
</tr>
<tr><td align="center">
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "*******", "*******");
mysql_select_db("*******",$db);
$sql = "INSERT INTO cbd (company,name,realname,firstappearance,team,height,weight,hair,eyes,powers,weakness,history) VALUES ('$company','$name','$realname','$firstappearance','$team','$height','$weight','$hair','$eyes','$powers','$weakness','$history')";
$result = mysql_query($sql) or die("Error: ".mysql_error());
echo "Thank you for your character bio submission!\n";
} else{
// display character submission form
?>
</td></tr>
</table>
<table align="center" border="0">
<form method="post" action="<?php echo $PHP_SELF?>">
<tr>
<td colspan="2" align="center"><img src=/images/submit.gif></td>
<tr>
<td align="center" colspan="2"><a href="/cbd/submitbio.php"><b>Submit a Character bio</b></a> | <a href="/cbd/bioslist.php"><b>Back to Character Index</b></a></td>
</tr>
<tr>
<td>Company:</td><td><input type="Text" name="company"></td>
</tr><tr>
<td>Character Name:</td><td><input type="Text" name="name"></td>
</tr><tr>
<td>Real Name:</td><td><input type="Text" name="realname"></td>
</tr><tr>
<td>First Appearance:</td><td><input type="Text" name="firstappearance"></td>
</tr><tr>
<td>Group Affiliation:</td><td><input type="Text" name="team"></td>
</tr><tr>
<td>Height:</td><td><input type="Text" name="height"></td>
</tr><tr>
<td>Weight:</td><td><input type="Text" name="weight"></td>
</tr><tr>
<td>Hair Color:</td><td><input type="Text" name="hair"></td>
</tr><tr>
<td>Eye Color:</td><td><input type="Text" name="eyes"></td>
</tr><tr>
<td valign="top">Powers and Abilities:</td><td><textarea rows="10" cols="40" name="powers"></textarea></td>
</tr><tr>
<td valign="top">Known Weaknesses:</td><td><textarea rows="5" cols="40" name="weakness"></textarea></td>
</tr><tr>
<td valign="top">History:</td><td><textarea rows="10" cols="40" name="history"></textarea></td>
</tr><tr>
<td colspan="2" align="center">
<input type="Submit" name="submit" value="Enter information">
</form>
</td></tr>
</table>
<?php
} // end if
?>
</body>
</html>
Now what would be an easy way to do what I'm asking, if not through the sql db? And if the sql db is my best bet... how would I do that?
Sorry still a newbie to all of this