Jump to content

[SOLVED] Delete Product Help


ccrevcypsys

Recommended Posts

Hello everyone,

Today i am having a problem with deleting rows off of my database table from the web site.

Heres the scenario:

    I need this so that people can delete their own music files they have uploaded.

 

  The problem is this, I have just simply taken this code from another part of the web site but i dont really understand why its not working. I am kinda new to php and all but understand it for the most part. What happens is when you click the [delete] link it askes you if you really want to delete if you click yes then it just takes you to the home page and does nothing.

	if($products == TRUE){
	if(isset($_GET['delete']) && $_GET["delete"]>0){

	// delete product
	$where = "productId=".$db->mySQLSafe($_GET["delete"]);
	$delete = $db->delete($glob['dbprefix']."CubeCart_inventory", $where);

	// set categories -1
	$cats = $db->select("SELECT cat_id FROM ".$glob['dbprefix']."CubeCart_cats_idx WHERE productId=".$db->mySQLSafe($_GET["delete"]));
	if($cats==TRUE){

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

				$db->categoryNos($cats[$i]['cat_id'], "-");

		}

	}

	// delete category index
	$where = "productId=".$db->mySQLSafe($_GET["delete"]);  
	$deleteIdx = $db->delete($glob['dbprefix']."CubeCart_cats_idx", $where);
	unset($record);


	// delete product options
	$record['product'] = $db->mySQLSafe($_GET["delete"]);
	$where = "product=".$db->mySQLSafe($_GET["delete"]);  
	$deleteOps = $db->delete($glob['dbprefix']."CubeCart_options_bot", $where);
	unset($record);

	if($delete == TRUE){

		$msg = "<p class='infoText'>".$lang['admin']['products']['delete_success']."</p>";

	} else {

		$msg = "<p class='warnText'>".$lang['admin']['products']['delete_fail']."</p>";

	}
}		

	$artist_console->assign("LANG_ORDER_SUMMARY",$lang['front']['viewOrder']['order_summary']);

	$artist_console->assign("LANG_PRODUCT",$lang['front']['viewOrder']['product']);
	$artist_console->assign("LANG_PRODUCT_CODE",$lang['front']['viewOrder']['product_code']);
	//$artist_console->assign("LANG_QUANTITY",$lang['front']['viewOrder']['quantity']);
	$artist_console->assign("LANG_POINTS",$lang['front']['viewOrder']['points']);
	$artist_console->assign("LANG_PRICE",$lang['front']['viewOrder']['price']);

	$totalPoints=0;
	for($i=0;$i<count($products); $i++){
		$pointsInfo=$db->select("SELECT * FROM ".$glob['dbprefix']."points where songid=".$db->mySQLsafe($products[$i]['productId']));
		if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$products[$i]['image'])){
			$artist_console->assign("SRC_PROD_THUMB",$GLOBALS['rootRel']."images/uploads/thumbs/thumb_".$products[$i]['image']);
		} else {
			$artist_console->assign("SRC_PROD_THUMB",$GLOBALS['rootRel']."skins/".$config['skinDir']."/styleImages/thumb_nophoto.gif");
		}
	$artist_console->assign("PRODUCT_ID",$products[$i]['productId']);
	$artist_console->assign("CAT_ID",$results[$i]['cat_id']);
		$artist_console->assign("TD_CLASS","");
		$artist_console->assign("VAL_PRODUCT",$products[$i]['name']);
		$artist_console->assign("VAL_PRODUCT_OPTS",$products[$i]['product_options']);
		//$artist_console->assign("VAL_IND_QUANTITY",$products[$i]['quantity']);
		$artist_console->assign("VAL_IND_PROD_COUNT",$pointsInfo[0]['download']);
		$artist_console->assign("VAL_IND_PRICE",priceFormat($products[$i]['price']));
		$artist_console->assign("LANG_DELETE_LINK","Delete"); 
		$artist_console->assign("LANG_EDIT_LINK","Edit"); 
		$artist_console->assign("VAL_IND_POINTS",$pointsInfo[0]['songPoints']);
		$totalPoints+=$pointsInfo[0]['songPoints'];
		$artist_console->parse("artist_console.session_true.order_true.repeat_products");

	}

        <div style=" overflow-y:scroll; max-height:300px;">
<table border="0" width="100%" cellspacing="0" cellpadding="3">
  <tr>
    <td colspan="2" class="tdcartTitle">{LANG_ORDER_SUMMARY}</td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="bottom" style="padding: 0px;">
<table width="100%" border="0" cellpadding="7" cellspacing="0" style="padding: 7px;">
      <tr>
        <td class="subHead"><strong>{LANG_PRODUCT}</strong></td>
        <td class="subHead"><strong>Copies sold</strong></td>
<!--        <td class="subHead"><strong>{LANG_QUANTITY}</strong></td>-->
<td class="subHead"><strong>{LANG_POINTS}</strong></td>
        <td align="right" class="subHead"><strong>{LANG_PRICE}</strong></td>
      </tr>
 <!-- BEGIN: repeat_products -->
  <tr>
  <td class="<?php echo $cellColor; ?>">
      <table><tr><td rowspan='3' align="center"><img src="{SRC_PROD_THUMB}" alt="{VAL_PRODUCT}" width="75" height="75" border="0" title="{VAL_PRODUCT}" /></td>
	<tr><td>{VAL_PRODUCT}<br>
	{VAL_PRODUCT_OPTS}</td></tr>
	[<a href="{VAL_EDIT_LINK}" class="txtDefault">{LANG_EDIT_LINK}</a>]
[<a {PERMISSION} href="javascript:decision('Are you sure you want to delete this?','index.php?act=artistConsole?delete={PRODUCT_ID}&cat_id={CAT_ID}');" class="txtLink">
Delete
</a>]   </table></td>
        <td class="{TD_CLASS}">{VAL_IND_PROD_COUNT}</td>
        <!--<td class="{TD_CLASS}">{VAL_IND_QUANTITY}</td>-->
<td class="{TD_CLASS}">{VAL_IND_POINTS}</td>
        <td align="right" class="{TD_CLASS}">{VAL_IND_PRICE}</td>
      </tr>
  <!-- END: repeat_products -->
        </table></td>
  <tr>
    <td style="border-top: 1px solid #000000;"><strong>TOTAL POINTS</strong></td>
    <td align="right" class="btmSubNav" style="border-top: 1px solid #000000;">
	<strong>{VAL_GRAND_TOTAL_POINTS}</strong></td>
    </tr>
    </table></td>
  </tr>
</table>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.