Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. from ASP to PHP

from ASP to PHP

Scheduled Pinned Locked Moved Web Development
helpphp
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aguest
    wrote on last edited by
    #1

    hi i am developping and e-trade website with PHP and i was programming with ASP before. i find a problem i don't find in PHP what can replace the dictionary object. can u help me.

    J 1 Reply Last reply
    0
    • A aguest

      hi i am developping and e-trade website with PHP and i was programming with ASP before. i find a problem i don't find in PHP what can replace the dictionary object. can u help me.

      J Offline
      J Offline
      Jack Puppy
      wrote on last edited by
      #2

      I haven't used asp in ages (don't think I ever used a Dictionary object), but assuming the Dictionary object is a key/value type deal, you can simply use a standard php array... $myarray = array('cat' => 'A cat says meow', 'dog' => 'A dog says woof'); or $myarray = array(); $myarray['cat'] = 'A cat says meow'; $myarray['dog'] = 'A dog says woof'; You can access an individual key/value pair like: $key = 'cat'; // if key is set, output its value if (isset($myarray[$key]))     echo $myarray[$key]; and you can iterate through all items like this... // retrieve all key/value pairs in array $key = ""; $value = ""; while (list($key, $value) = each($myarray))      echo $key . ' => ' . $value; There should be lots of other examples in the array section of the php help file.

      My 20 Favorite Films

      A 1 Reply Last reply
      0
      • J Jack Puppy

        I haven't used asp in ages (don't think I ever used a Dictionary object), but assuming the Dictionary object is a key/value type deal, you can simply use a standard php array... $myarray = array('cat' => 'A cat says meow', 'dog' => 'A dog says woof'); or $myarray = array(); $myarray['cat'] = 'A cat says meow'; $myarray['dog'] = 'A dog says woof'; You can access an individual key/value pair like: $key = 'cat'; // if key is set, output its value if (isset($myarray[$key]))     echo $myarray[$key]; and you can iterate through all items like this... // retrieve all key/value pairs in array $key = ""; $value = ""; while (list($key, $value) = each($myarray))      echo $key . ' => ' . $value; There should be lots of other examples in the array section of the php help file.

        My 20 Favorite Films

        A Offline
        A Offline
        aguest
        wrote on last edited by
        #3

        the good in the Dictionary object is that can open a session in the client part(the pc of the client) and you can store the information. in the case that he refresh the page all the information still in his pc ,and that what i am looking for ,and i don't know if i can do that with PHP.

        J 1 Reply Last reply
        0
        • A aguest

          the good in the Dictionary object is that can open a session in the client part(the pc of the client) and you can store the information. in the case that he refresh the page all the information still in his pc ,and that what i am looking for ,and i don't know if i can do that with PHP.

          J Offline
          J Offline
          Jack Puppy
          wrote on last edited by
          #4

          Session management is available in PHP. The default setup will store the session data in a temporary folder on the server. You can add your own custom handlers to provide your own storage method if need be. (I save session data to an mysql table) You need to call session_start() on each page you'll be manipulating session data. You can access the session data via the $_SESSION superglobal: page1.php <?php // always call session_start 1st session_start(); $_SESSION['session_data_item_1'] = 'one'; $_SESSION['session_data_item_2'] = 'two'; ?> <a href="page2.php">Goto Page 2</a> page2.php <?php // always call session_start 1st session_start(); echo $_SESSION['session_data_item_1']; echo $_SESSION['session_data_item_2']; ?> php session tutorials: http://www.phpfreaks.com/tutorials/41/0.php http://www.free2code.net/plugins/articles/read.php?id=184 Lookup the session_ functions in php help file for more examples.

          Pssst. You see that little light on your monitor? That's actually a spy camera, and I'm tracking your every move...

          A 1 Reply Last reply
          0
          • J Jack Puppy

            Session management is available in PHP. The default setup will store the session data in a temporary folder on the server. You can add your own custom handlers to provide your own storage method if need be. (I save session data to an mysql table) You need to call session_start() on each page you'll be manipulating session data. You can access the session data via the $_SESSION superglobal: page1.php <?php // always call session_start 1st session_start(); $_SESSION['session_data_item_1'] = 'one'; $_SESSION['session_data_item_2'] = 'two'; ?> <a href="page2.php">Goto Page 2</a> page2.php <?php // always call session_start 1st session_start(); echo $_SESSION['session_data_item_1']; echo $_SESSION['session_data_item_2']; ?> php session tutorials: http://www.phpfreaks.com/tutorials/41/0.php http://www.free2code.net/plugins/articles/read.php?id=184 Lookup the session_ functions in php help file for more examples.

            Pssst. You see that little light on your monitor? That's actually a spy camera, and I'm tracking your every move...

            A Offline
            A Offline
            aguest
            wrote on last edited by
            #5

            i am making a e-trade website and i have for exemple 03 products 1) Product N°1 = 5$ 2) Product N°1 = 10$ 1) Product N°1 = 8$ and when the consumer choise one product one row of matrix will be created in an other page with the name of the product and the price ---------------- product1 / 5$ ---------------- and like that with the second product and the third . and i want to store this session in the PC of the client ,cause the client can delete a product after he choise it.

            J 1 Reply Last reply
            0
            • A aguest

              i am making a e-trade website and i have for exemple 03 products 1) Product N°1 = 5$ 2) Product N°1 = 10$ 1) Product N°1 = 8$ and when the consumer choise one product one row of matrix will be created in an other page with the name of the product and the price ---------------- product1 / 5$ ---------------- and like that with the second product and the third . and i want to store this session in the PC of the client ,cause the client can delete a product after he choise it.

              J Offline
              J Offline
              Jack Puppy
              wrote on last edited by
              #6

              You can add/update/delete any type of variable at anytime when you use php sessions. Here's a general take at what I'd do for an e-cart app. Firstly, I'd place all e-cart code in a separate file, that way you can include it in any file you want. (even better, you can make a class for it) include_ecart.php: (not checked for errors) <?php   /* e-cart related functions */   function does_ecart_exist()   {     // if 'ecart' session variable is set, it exists     return (isset($_SESSION['ecart']));   }   function is_item_in_ecart($product_id)   {     // make sure the e-cart exists!     if (!does_ecart_exist())       return (false);     return (isset($_SESSION['ecart'][$product_id]));   }   function add_item_to_ecart($product_id, $product_name, $unit_price, $quantity)   {     // make sure the e-cart exists!     if (!does_ecart_exist())       return (false);     // todo: determine what to do if item already in cart...     // if (is_item_in_ecart($product_id))     // update or return error?     // create an array to hold the product data     $product_data = array('name' => $product_name, 'price' => $unit_price, 'quantity' => $quantity);     // add the product to the e-cart array, using it's id as the key     $_SESSION['ecart'][$product_id] = $product_data;     return (true);   }   function view_ecart_contents()   {     // make sure the e-cart exists!     if (!does_ecart_exist())       return (false);     // grab each item in the cart, and print out data     $product_id = 0;     $product_data = array();     while (list($product_id, $product_data) = each($_SESSION['ecart']))     {       printf('Product Id: %1$s, Name: %2$s, Price: %3$s, Quantity: %4$s',         $product_id,        &n

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups