joshgarrod Posted June 29, 2007 Share Posted June 29, 2007 Hi everyone, this task i have is really getting to me. I have an image uploader that works and i then want to use the images uploaded in a form which adds stock. i already have an add stock form but i want to add a new field and state the path of the image and then display the image as a small thumbnail in a table on another page and then wen the thumbnail is clicked on i would like it to enlarge in a small popup window. it seems like quite a mission to me and no matter what i do i cant get it to worhelp. thanks alot below is the script for both pages: Add stock page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Add stock</title> </head> <body> <font face="Arial, Helvetica, sans-serif"> <? $usr = "dfthh $pwd = "idfghh $db = "dfhgh $host = "localhost"; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } ?> <HTML> <HEAD> </font> <TITLE>Add stock</TITLE> <font face="Arial, Helvetica, sans-serif"> </HEAD> <BODY BGCOLOR="#FFFFFF"> </font> <P><FONT SIZE=5 face="Arial, Helvetica, sans-serif"><B> Add stock </B> </FONT></P> <font face="Arial, Helvetica, sans-serif"> <? # this is processed when the form is submitted # back on to this page (POST METHOD) if ($REQUEST_METHOD=="POST") { # double-up apostrophes $StockDescription = str_replace("'","''",$StockDescription); $StockNumber = str_replace("'","''",$StockNumber); # setup SQL statement $SQL = " INSERT INTO stock "; $SQL = $SQL . " (StockNumber, ItemPrice, StockDescription) VALUES "; $SQL = $SQL . " ('$StockNumber','$ItemPrice','$StockDescription') "; #execute SQL statement $result = mysql_db_query($db,"$SQL",$cid); $ID=mysql_insert_id(); # check for error if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo ("<P><B>New stock item added</B></P>\n"); } ?> </font> <FORM NAME="fa" ACTION="addStock.php" METHOD="POST"> <TABLE> <TR><TD><font face="Arial, Helvetica, sans-serif"><B>Stock ID: </B> </font></TD><TD><font face="Arial, Helvetica, sans-serif"> <INPUT TYPE="text" NAME="ID" value="<?php echo $ID; ?>" SIZE=40> </font></TD></TR> <TR><TD><font face="Arial, Helvetica, sans-serif"><B>Stock Number:</B> </font></TD><TD><font face="Arial, Helvetica, sans-serif"> <INPUT TYPE="text" NAME="StockNumber" SIZE=40> </font></TD></TR> <TR><TD><font face="Arial, Helvetica, sans-serif"><B>Item Price: </B> </font></TD><TD><font face="Arial, Helvetica, sans-serif"> <INPUT TYPE="text" NAME="ItemPrice" VALUE="£" SIZE=40> </font></TD></TR> <TR><TD VALIGN=TOP><font face="Arial, Helvetica, sans-serif"><B>Description: </B> </font></TD><TD><font face="Arial, Helvetica, sans-serif"> <textarea name="StockDescription" rows=5 cols=40></textarea> </font></TD> </TR> <TR><TH COLSPAN=2><P><font face="Arial, Helvetica, sans-serif"> <INPUT TYPE="submit" VALUE="Add stock"> </font></P></TH></TR> </TABLE> <p align="center"><font face="Arial, Helvetica, sans-serif"><a href="sparesAdminPage.html">Back</a></font></p> </FORM> <font face="Arial, Helvetica, sans-serif"> <? mysql_close($cid); ?> </font> </BODY> </HTML> </body> </html> view stock page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>View spares stock</title> <style type="text/css"> <!-- #Layer1 { position:absolute; left:14px; top:63px; width:196px; height:22px; z-index:1; } .style1 {font-family: Arial, Helvetica, sans-serif} .style2 {font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; } .style3 {color: #0000FF} #Layer2 { position:absolute; left:378px; top:63px; width:87px; height:21px; z-index:2; } .style4 {color: #0000FF; font-family: Arial, Helvetica, sans-serif; } --> </style> </head> <body> <div class="style1" id="Layer1"><a href="index.php?page=Search1" class="style3">Click here to search stock </a></div> <div class="style4" id="Layer2"><a href="www.stowmarketcaravans.co.uk/viewStockC1.php" class="style3">Back</a></div> <TABLE WIDTH="100%" HEIGHT="40" BORDER="0" CELLPADDING="10" CELLSPACING="5" BGCOLOR="#FFFFFF"> <TR bgcolor="#F0F0F0"> <TD width="10%" HEIGHT="40" ALIGN=bottom class="style1" ID="header"><strong><em><FONT SIZE="1" COLOR="#8A8A8A">ID number </FONT></em></strong></TD> <TD width="12%" ALIGN=middle class="style1" ID="header"><strong><em><FONT COLOR="#8A8A8A" SIZE="1">Stock number </FONT></em></strong></TD> <TD width="64%" ALIGN=middle class="style1" ID="header"><strong><em><FONT COLOR="#8A8A8A" SIZE="1">Stock description </FONT></em></strong></TD> <TD width="14%" ALIGN=middle class="style1" ID="header"><strong><em><FONT COLOR="#8A8A8A" SIZE="1">Item price inc. VAT </FONT></em></strong></TD> </TR> <TR> <TD HEIGHT="40" ALIGN=middle class="style2" ID="header"> </TD> <TD ALIGN=middle class="style2" ID="header"> </TD> <TD ALIGN=middle class="style2" ID="header"> </TD> <TD ALIGN=middle class="style2" ID="header"> </TD> </TR> <?php $con = mysql_connect("localhost","wefe","ixwegweg"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("wegr21", $con); $query = "SELECT * FROM `stock`"; $result = mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $a=mysql_result($result,$i,"ID"); $b=mysql_result($result,$i,"StockNumber"); $c=mysql_result($result,$i,"StockDescription"); $d=mysql_result($result,$i,"ItemPrice"); print ($i % 2) ? "<tr bgcolor=\"ffffff\">" : "<tr bgcolor=\"fff000\">"; print "<td align=center>$a</td>"; print "<td align=center>$b</td>"; print "<td align=center>$c</td>"; print "<td align=center>$d</td>"; ++$i; } ?> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.