Help a Newbie?
Posted: Mon Nov 29, 2004 8:45 pm
Hi everyone!!
i asked for some help on another forum, but no one replied...just looking around to see if ANYONE can help
my friend is helping me write a script for my webpage, but he doesn't know how to help me on this one. I have a form (script below) to add stuff to my database, but I want it to also let me upload photos. So, then when I go to the online form, I can just add all my data and the pics right there, and if other people want to help me, they can go in there and add the photos too, without having to use my admin program. So, where it says "thumba", "thumbb" etc, that's where I want to have a place to upload photos. And then when i make my display page, it shows up as thumbnails, but when you click on it, a fuill size image appears. Does that makes sense? Can anyone help me? I've tried to find a script, but i just don't understand how to put it in the script I already made...and since it took me forever to get this script to work, I don't want to mess it up!! You guys are so great if you can help me!!!!
here's my script:
i asked for some help on another forum, but no one replied...just looking around to see if ANYONE can help
my friend is helping me write a script for my webpage, but he doesn't know how to help me on this one. I have a form (script below) to add stuff to my database, but I want it to also let me upload photos. So, then when I go to the online form, I can just add all my data and the pics right there, and if other people want to help me, they can go in there and add the photos too, without having to use my admin program. So, where it says "thumba", "thumbb" etc, that's where I want to have a place to upload photos. And then when i make my display page, it shows up as thumbnails, but when you click on it, a fuill size image appears. Does that makes sense? Can anyone help me? I've tried to find a script, but i just don't understand how to put it in the script I already made...and since it took me forever to get this script to work, I don't want to mess it up!! You guys are so great if you can help me!!!!
here's my script:
Code: Select all
<?
$host="******";
$user="******";
$password="******";
$dbname="******";
$dbtable="******";
$homepage="******.php";
$dbh=mysql_connect ("******", "******", "******") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("w******");
print "<html>\n";
print "<head>\n";
print "<title>******</title>\n";
print "</head>\n\n";
// PREADD CONTENT
if ($action == "preadd")
{
?>
</head>
<body>
<p>You are adding a new jersey:</p>
<p>
<form action="<? print $homepage ?>" method="post" enctype="multipart/form-data">
<table width="100%" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td><p>First:</p></td>
<td> <input name="first" type="text" size="18"> </td>
</tr>
<tr>
<td><p>Last:</p></td>
<td><p>
<input name="last" type="text" size="18">
</p></td>
</tr>
<tr>
<td><p>Thumb A</p></td>
<td><p>
<input name="thumba" type="text" size="18">
</p></td>
</tr>
<tr>
<td><p>Thumb B</p></td>
<td><p>
<input name="thumbb" type="text" size="18">
</p></td>
</tr>
<tr>
<td><p>Thumb C</p></td>
<td><p>
<input name="thumbc" type="text" size="18">
</p></td>
</tr>
<tr>
<td><p>Thumb D</p></td>
<td><p>
<input name="thumbd" type="text" size="18">
</p></td>
</tr>
<tr>
<td><p>Team</p></td>
<td><p>
<input name="team" type="text" size="18">
</p></td>
</tr>
</table>
<p>
<input name="submit" type="submit" value="Add Entry">
</p>
<p>
<input type="hidden" name="action" value="add">
</p>
</form>
<?
}
// ADD CONTENT
if ($action == "add")
{
$last = addslashes($last);
$sql = "insert into $dbtable (first,last,thumba,thumbb,thumbc,thumbd,team) values ('$first','$last','$thumba','$thumbb','$thumbc','$thumbd');";
$result = mysql_query($sql, $dbh) or die( mysql_error() );
if ($result)
{
print "You have successfully added an Entry for <b>$last</b><br>\n";
}
else
{
print "Error: Unable to Add Entry<br>";
}
print "<br>Click below to be redirected to the Home Page.</p>";
print "<b><a href='$homepage'>Home Page</a></b>";
}
// LIST ENTRIES (DEFAULT)
if ($action == "list" || $action == "")
{
?>
</head>
<body>
<p>Main Page</p>
<table width="60%" border="1">
<p>ї<a href="<? print $homepage ?>?action=preadd">Add New</a>] </p>
<p>
<?
$sql = "select id, last, first from $dbtable order by id desc;";
$result = mysql_query($sql, $dbh) or die( mysql_error() );
?>
<?
for ($x = 0; $x < mysql_num_rows($result); $x++)
{
$id = mysql_result($result, $x, "id");
$last = mysql_result($result, $x, "last");
$first = mysql_result($result, $x, "first");
print "<tr>\n";
print "<td><p align='center'>";
print "$id";
print "</p></td>\n";
print "<td><p align='center'>";
print "$last";
print "</p></td>\n";
print "<td><p align='center'>";
print "$first";
print "</p></td>\n";
}
print "</table>\n";
}
?>
</body>
</html>