Jump to content

Need a little help with images...adding more of them in a shopping cart


OTYS

Recommended Posts

Hello there.. I'm in need of a little help if someone can either point me in the right direction or...with Gods help..show me how.. I have installed shop-script--- shop-script.com the free version because, well, I'm broke, but what I really need to do is to be able to add multiple images of any given item. We run a (yard sale) site and like eBay and other used items sites people can't hold it (The items being sold) in their hands, pick it up, touch it, etc so I need to be able to use plenty of images, but unfortunately the free version of shop-script only allows a few images, the main one, a larger version and the thumbnail. I need to be able to add several images..maybe 6 or so, but the problem is I don't have the first clue where to begin with this. I might be able to figure it out if someone is willing to show me how.. Any takers?

 

Thanks ahead of time.

 

OTYS

ONLY 16?? Holy moley.. Anyway..That's quite a request, but I'll eventually sift through all the pages of code. it might take a few days, but I'll get there eventually.

I'm 49 going on 16.. Be glad you learn all this at your age.. Try learning half of it at 49... uhhhg.. (Hint: It ain't gonna get any easier once you hit 30) Then it's all parallel even though most people say it's all downhill.. it isn't..

Thanks  OTYS

 

I don't know if any of this is what I'm looking for or not. i just grabbed what looked like photo info.. I can keep hunting, but I was also almost asleep too..

 

			//delete old product photos if they're being replaced

		$q = db_query("SELECT picture, big_picture, thumbnail FROM ".PRODUCTS_TABLE." WHERE productID='".$_POST["save_product"]."'") or die (db_error());

		$row = db_fetch_row($q);



		//generating query



		$s = "UPDATE ".PRODUCTS_TABLE." SET categoryID='".$_POST["categoryID"]."', name='".$_POST["name"]."', Price='".$_POST["price"]."', description='".$_POST["description"]."', in_stock=".$instock.", customers_rating='".$_POST["rating"]."', brief_description='".$_POST["brief_description"]."', list_price='".$_POST["list_price"]."', product_code='".$_POST["product_code"]."'";



		$s1 = "";



		//old pictures?

		if (isset($_FILES["picture"]) && $_FILES["picture"]["name"])

		{

			//delete old picture

			if ($row[0] && file_exists("./products_pictures/".$row[0]))

				unlink("./products_pictures/".$row[0]);

		}

		if (isset($_FILES["big_picture"]) && $_FILES["big_picture"]["name"])

		{

			//delete old picture

			if ($row[1] && file_exists("./products_pictures/".$row[1]))

				unlink("./products_pictures/".$row[1]);

		}

		if (isset($_FILES["thumbnail"]) && $_FILES["thumbnail"]["name"])

		{

			//delete old picture

			if ($row[2] && file_exists("./products_pictures/".$row[2]))

				unlink("./products_pictures/".$row[2]);

		}



		$pid = $_POST["save_product"];



	}

	else

	{

		//add new product

		db_query("INSERT INTO ".PRODUCTS_TABLE." (categoryID, name, description, customers_rating, Price, in_stock, customer_votes, items_sold, enabled, brief_description, list_price, product_code, picture, thumbnail, big_picture) VALUES ('".$_POST["categoryID"]."','".$_POST["name"]."','".$_POST["description"]."', 0, '".$_POST["price"]."', ".$instock.", 0, 0, 1, '".$_POST["brief_description"]."', '".$_POST["list_price"]."', '".$_POST["product_code"]."','','','');") or die (db_error());

		$pid = db_insert_id();



		$dont_update = 1; //don't update product



		$s  = "";

		$s1 = "UPDATE ".PRODUCTS_TABLE." SET categoryID=categoryID";

	}



	//add pictures?

	//regular photo

	if (isset($_FILES["picture"]) && $_FILES["picture"]["name"] && preg_match('/\.(jpg|jpeg|gif|jpe|pcx|bmp)$/i', $_FILES["picture"]["name"])) //upload

	{

		$_FILES["picture"]["name"] = str_replace(" ","_",$_FILES["picture"]["name"]);

		$r = move_uploaded_file($_FILES["picture"]["tmp_name"], "./products_pictures/".$_FILES["picture"]["name"]);

		if (!$r) //failed 2 upload

		{

			echo "<center><font color=red>".ERROR_FAILED_TO_UPLOAD_FILE."</font>\n<br><br>\n";

			echo "<a href=\"javascript:window.close();\">".CLOSE_BUTTON."</a></center></body>\n</html>";

			exit;

		}



		SetRightsToUploadedFile( "./products_pictures/".$_FILES["picture"]["name"] );



		$s .= ", picture='".$_FILES["picture"]["name"]."'";

		$s1.= ", picture='".$_FILES["picture"]["name"]."'";

	}

	//enlarged photo

	if (isset($_FILES["big_picture"]) && $_FILES["big_picture"]["name"] && preg_match('/\.(jpg|jpeg|gif|jpe|pcx|bmp)$/i', $_FILES["big_picture"]["name"]))

	{ 

		$_FILES["big_picture"]["name"] = str_replace(" ","_",$_FILES["big_picture"]["name"]);

		$r = move_uploaded_file($_FILES["big_picture"]["tmp_name"], "./products_pictures/".$_FILES["big_picture"]["name"]);

		if (!$r) //failed 2 upload

		{

			echo "<center><font color=red>".ERROR_FAILED_TO_UPLOAD_FILE."</font>\n<br><br>\n";

			echo "<a href=\"javascript:window.close();\">".CLOSE_BUTTON."</a></center></body>\n</html>";

			exit;

		}



		SetRightsToUploadedFile( "./products_pictures/".$_FILES["big_picture"]["name"] );



		$s .= ", big_picture='".$_FILES["big_picture"]["name"]."'";

		$s1.= ", big_picture='".$_FILES["big_picture"]["name"]."'";

	}

	//thumbnail

	if (isset($_FILES["thumbnail"]) && $_FILES["thumbnail"]["name"] && preg_match('/\.(jpg|jpeg|gif|jpe|pcx|bmp)$/i', $_FILES["thumbnail"]["name"]))

	{

		$_FILES["thumbnail"]["name"] = str_replace(" ","_",$_FILES["thumbnail"]["name"]);

		$r = move_uploaded_file($_FILES["thumbnail"]["tmp_name"], "./products_pictures/".$_FILES["thumbnail"]["name"]);

		if (!$r) //failed 2 upload

		{

			echo "<center><font color=red>".ERROR_FAILED_TO_UPLOAD_FILE."</font>\n<br><br>\n";

			echo "<a href=\"javascript:window.close();\">".CLOSE_BUTTON."</a></center></body>\n</html>";

			exit;

		}



		SetRightsToUploadedFile( "./products_pictures/".$_FILES["thumbnail"]["name"] );



		$s .= ", thumbnail='".$_FILES["thumbnail"]["name"]."'";

		$s1.= ", thumbnail='".$_FILES["thumbnail"]["name"]."'";

	}http://answercenter.ebay.com/thread.jspa?forumID=3&threadID=900147111&anticache=1217637980418



	if (!isset($dont_update)) //update product info

	{

		$s .= " WHERE productID='".$_POST["save_product"]."'";

		db_query($s) or die (db_error());

		$productID = $_POST["save_product"];

	}

	else //don't update (insert query is already completed)

	{

		$s1.= " WHERE productID=$pid";

		db_query($s1) or die (db_error());

		$productID = $pid;

	}



	update_products_Count_Value_For_Categories(0);



	//close window

	echo "<script>\n";

	echo "window.opener.location.reload();\n";

	echo "window.close();\n";

	echo "</script>\n</body>\n</html>";

	exit;

}

else //get product from db

{

	if ($_GET["productID"])

	{



		$q = db_query("SELECT categoryID, name, description, customers_rating, Price, picture, in_stock, thumbnail, big_picture, brief_description, list_price, product_code FROM ".PRODUCTS_TABLE." WHERE productID='".$_GET["productID"]."'") or die (db_error());

		$row = db_fetch_row($q);

			if (!$row) //product wasn't found

		{

			echo "<center><font color=red>".ERROR_CANT_FIND_REQUIRED_PAGE."</font>\n<br><br>\n";

			echo "<a href=\"javascript:window.close();\">".CLOSE_BUTTON."</a></center></body>\n</html>";

			exit;

		}



		if (isset($_GET["picture_remove"])) //delete items picture from server if requested

		{

			if ($_GET["picture_remove"] && file_exists("./products_pictures/".$row[$_GET["picture_remove"]]))

				unlink("./products_pictures/".$row[$_GET["picture_remove"]]);

			$picture = "none";

		}



		if (isset($_GET["delete"])) //delete product

		{

			//at first photos...

			if ($row[5] != "none" && $row[5] != "" && file_exists("./products_pictures/".$row[5]))

				unlink("./products_pictures/".$row[5]);

			if ($row[7] != "none" && $row[7] != "" && file_exists("./products_pictures/".$row[7]))

				unlink("./products_pictures/".$row[7]);

			if ($row[8] != "none" && $row[8] != "" && file_exists("./products_pictures/".$row[8]))

				unlink("./products_pictures/".$row[8]);



			$q = db_query("DELETE FROM ".PRODUCTS_TABLE." WHERE productID='".$_GET["productID"]."'") or die (db_error());



			//close window

			echo "<script>\n";

			echo "window.opener.location.reload();\n";

			echo "window.close();\n";

			echo "</script>\n</body>\n</html>";

			exit;

		}



		$title = $row[1];



	}

	else //creating new item

	{

		$title = ADMIN_PRODUCT_NEW;

		$cat = isset($_GET["categoryID"]) ? $_GET["categoryID"] : 0;

		$row = array($cat,"","","",0,"",1,"","","",0,"");

	}

}







?>



<html>



<head>

<link rel=STYLESHEET href="images/backend/style-backend.css" type="text/css">

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo DEFAULT_CHARSET;?>">

<title><?php echo ADMIN_PRODUCT_TITLE;?></title>

<script>

function confirmDelete(question, where)

{

temp = window.confirm(question);

if (temp) //delete

{

	window.location=where;

}

}

function open_window(link,w,h) //opens new window

{

var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";

wishWin = window.open(link,'wishWin',win);

}

</script>

</head>



<body bgcolor=#FFFFE2>

<center>

<p>

<b><?php echo $title; ?></b>



<form enctype="multipart/form-data" action="products.php" method=post>



<table width=100% border=0 cellpadding=3 cellspacing=0>



<tr>

<td align=right><?php echo ADMIN_CATEGORY_PARENT;?></td>

<td>

<select name="categoryID">

<option value="0"><?php echo ADMIN_CATEGORY_ROOT;?></option>

<?php

//show categories select element

$cats = fillTheCList(0,0);

for ($i=0; $i<count($cats); $i++)

{

	echo "<option value=\"".$cats[$i][0]."\"";

	if ($row[0] == $cats[$i][0]) //select category

		echo " selected";

	echo ">";

	for ($j=0;$j<$cats[$i][5];$j++) echo "  ";

	echo $cats[$i][1];

	echo "</option>";

}

?>

</select>

</td>

</tr>



<tr>

<td align=right><?php echo ADMIN_PRODUCT_NAME;?></td>

<td><input type="text" name="name" value="<?php echo str_replace("\"",""",$row[1]); ?>"></td>

</tr>



<tr>

<td align=right><?php echo ADMIN_PRODUCT_CODE;?></td>

<td><input type="text" name="product_code" value="<?php echo str_replace("\"",""",$row[11]); ?>"></td>

</tr>



<?php	if ($_GET["productID"]) { ?>

<tr>

<td align=right><?php echo ADMIN_PRODUCT_RATING;?>:</td>

<td><input type=text name="rating" value="<?php echo str_replace("\"",""",$row[3]); ?>"></b></td>

</tr>



<?php }; ?>



<tr>

<td align=right><?php echo ADMIN_PRODUCT_PRICE;?>, <?php echo $currency_iso_3; ?><br>(<?php echo STRING_NUMBER_ONLY;?>):</td>

<td><input type="text" name="price" value=<?php echo $row[4]; ?>></td>

</tr>



<tr>

<td align=right><?php echo ADMIN_PRODUCT_LISTPRICE;?>, <?php echo $currency_iso_3; ?><br>(<?php echo STRING_NUMBER_ONLY;?>):</td>

<td><input type="text" name="list_price" value=<?php echo $row[10]; ?>></td>

</tr>



<?php

if ($row[6]<0) $is = 0;

else $is = $row[6];



?>

<tr>

<td align=right><?php echo ADMIN_PRODUCT_INSTOCK;?>:</td>

<td><input type="checkbox" name="in_stock"<?php if ($is > 0) echo " checked"; ?>></td>

</tr>





<tr><td> </td></tr>



<tr>

<td align=right><?php echo ADMIN_PRODUCT_PICTURE;?></td>

<td><input type="file" name="picture"></td>

<tr><td></td><td>

<?php

if ($row[5]!="" && file_exists("./products_pictures/".$row[5]))

{

	echo "<a class=small href=\"products_pictures/".$row[5]."\">$row[5]</a>\n";

	echo "<br><a href=\"javascript:confirmDelete('".QUESTION_DELETE_PICTURE."','products.php?productID=".$_GET["productID"]."&picture_remove=5');\">".DELETE_BUTTON."</a>\n";

}

else echo "<font class=average color=brown>".ADMIN_PICTURE_NOT_UPLOADED."</font>";

?>

</td>

</tr>

<tr>

<td align=right><?php echo ADMIN_PRODUCT_THUMBNAIL;?></td>

<td><input type="file" name="thumbnail"></td>

<tr><td></td><td>

<?php

if ($row[7]!="" && file_exists("./products_pictures/".$row[7]))

{

	echo "<a class=small href=\"products_pictures/".$row[7]."\">$row[7]</a>\n";

	echo "<br><a href=\"javascript:confirmDelete('".QUESTION_DELETE_PICTURE."','products.php?productID=".$_GET["productID"]."&picture_remove=7');\">".DELETE_BUTTON."</a>\n";

}

else echo "<font class=average color=brown>".ADMIN_PICTURE_NOT_UPLOADED."</font>";

?>

</td>

</tr>

<tr>

<td align=right><?php echo ADMIN_PRODUCT_BIGPICTURE;?></td>

<td valign=top><input type="file" name="big_picture"></td>

<tr><td></td><td valign=top>

<?php

if ($row[8] && file_exists("./products_pictures/".$row[8]))

{

	echo "<a class=small href=\"products_pictures/".$row[8]."\">$row[8]</a>\n";

	echo "<br><a href=\"javascript:confirmDelete('".QUESTION_DELETE_PICTURE."','products.php?productID=".$_GET["productID"]."&picture_remove=8');\">".DELETE_BUTTON."</a>\n";

}

else echo "<font class=average color=brown>".ADMIN_PICTURE_NOT_UPLOADED."</font>";

?>

</td>

</tr>





<tr>

<td align=right><?php echo ADMIN_PRODUCT_DESC;?><br>(HTML):</td>

<td><textarea name="description" rows=15 cols=40><?php echo str_replace("<","<",$row[2]); ?></textarea></td>

</tr>



<tr>

<td align=right><?php echo ADMIN_PRODUCT_BRIEF_DESC;?><br>(HTML):</td>

<td><textarea name="brief_description" rows=7 cols=40><?php echo str_replace("<","<",$row[9]); ?></textarea></td>

</tr>



</table>





<p><center>

<input type="submit" value="<?php echo SAVE_BUTTON;?>" width=5>

<input type="hidden" name="save_product" value=<?php echo $_GET["productID"]; ?>>

<input type="button" value="<?php echo CANCEL_BUTTON;?>" onClick="window.close();">

<?php	if ($_GET["productID"]) echo "<input type=button value=\"".DELETE_BUTTON."\" onClick=\"confirmDelete('".QUESTION_DELETE_CONFIRMATION."','products.php?productID=".$_GET["productID"]."&delete=1');\">"; ?>

</center></p>

</form>





</center>

</body>



</html>

 

Just let me know if I'm in the right ball park or not..

 

Thanks,

O

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.