1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Help Convert PHP code to ASP

Discussion in 'C#' started by StealthRT, Mar 15, 2006.

  1. #1
    Hey all i am in need of some help converting this php code to ASP. Its for a drag and drop style cart thing.
    
    <?php
    error_reporting(E_ALL ^ E_NOTICE);
    session_start();
    
    $products = array(1 => 'Mug', 2 => 'T-Shirt');
    switch($_POST['action'])
    {
        case 'add':
        add();
        break;
        case 'remove':
        remove();
        break;
        default:
        index();
        break;
    }
    
    function add()
    {
        $parts = explode('_', $_POST['id']);
        $id = (int)$parts[1];
        $_SESSION['cart'][$id] ++;
        doCart();
        return;
    }
    
    function doCart()
    {
        global $products;
        if(is_array($_SESSION['cart']))
        {
            foreach($_SESSION['cart'] AS $item => $qty) {
    ?>
     <div>
      <?php for($i = 0; $i < $qty; $i++) { ?>
       <img alt="Product1" class="cart-items" id="item_<?php echo $item?>_<?php echo $i?>" src="shop_files/product<?php echo $item?>.png" style="position: relative;">
       <script type="text/javascript">new Draggable('item_<?php echo $item?>_<?php echo $i?>', {revert:true})</script>
      <?php } ?>
      <span class="title">
       <?php echo $products[$item]?> (<?php echo $qty ?>)
      </span>
    </div>
    <?php
            }
        }
        if(empty($_SESSION['cart']))
        {
            echo "Your Cart Is Empty";
        }
    }
    
    function remove()
    {
        $parts = explode('_', $_POST['id']);
        $id = (int)$parts[1];
        $_SESSION['cart'][$id] --;
        if($_SESSION['cart'][$id] == 0)
        {
            unset($_SESSION['cart'][$id]);
        }
    
        doCart();
        return;
    }
    
    function index()
    {
    ?>
    
    PHP:
    I would be very greatful if someone could convert this for me as i have all ASP pages and i really only know how to call my database and data from it using ASP code.
    SEMrush
    Thank you for your time!
    David
     
    StealthRT, Mar 15, 2006 IP
    SEMrush
  2. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    sorry man, that's pretty darn complex. it could be done, but it would take alot of time to do it - and without being able to test the conversion in your server environment - it would be next to impossible.
     
    vectorgraphx, Mar 16, 2006 IP
  3. StealthRT

    StealthRT Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey vectorgraphx,
    Thanks for the reply! Well i was hoping it would be a little easier than that. I guess ill have to post it on one of those "name your price" for converting my code over to ASP.

    Thanks anyways!

    David
     
    StealthRT, Mar 16, 2006 IP
  4. warlock_cro

    warlock_cro Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    there are some online conversion tools .. you might want to check it on google ..
     
    warlock_cro, Mar 20, 2006 IP