Solved

ASP to PHP

Posted on 2011-09-23
6
415 Views
Last Modified: 2012-06-27
Hello,

I have attached a code sample of ASP (Active Server Pages) . CUrrently Iam switching from ASP to PHP and I need to learn and understand PHP- Can someone please post the correct code for PHP here please.

Ocrana
0
Comment
Question by:Ocrana
6 Comments
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 36585423
There is no code attached to the question.

0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36585437
Attach OR paste your code
0
 

Author Comment

by:Ocrana
ID: 36585965
Sorry, seems seomething went wrong. Here ist the code.
for i = 0 to 8
			nQty = CInt(Split(Request.Form("plimus_prod"), ",")(i))  'Wenn die Anzahl größer als 0 ist

			if nQty > 0 then
				if n = 0 then
					strQuery = strQuery & "contractId=" & trim(Split(Request.Form("plimus_code"), ",")(i)) & "&numberOfPromotionContract=TOTAL_PROD"
					strQty = strQty & "&quantity=" & CInt(Split(Request.Form("plimus_prod"), ",")(i))
				else
					strQuery = strQuery & "&promoteContractId" & n - 1 & "=" & trim(Split(Request.Form("plimus_code"), ",")(i)) & "&promoteContractFlag" & n - 1 & "=Y&addPromoteContract" & n - 1 & "=Y"
					strQty = strQty & "&promoteQuantity" & n - 1 & "=" & CInt(Split(Request.Form("plimus_prod"), ",")(i))
				end if

				n = n + 1
			end if
		next
		
		strQuery = Replace(strQuery, "TOTAL_PROD", n) & strQty

Open in new window

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36586074
What is n? Check what is n and try below code

<?php
$strQuery = "";
$strQty =""
for ($i=0; $i<8; $i++)
  {
     $plimus_prod =  explode(",", $_REQUEST['plimus_prod']);
     $nQty = (int)$plimus_prod[i];
  
    if($nQty > 0)
    {
       $plimus_code =  explode(",", $_REQUEST['plimus_code']);
       if($n == 0)
       {
         $strQuery = $strQuery + "contractId=" + trim($plimus_code[i]) + "&numberOfPromotionContract=TOTAL_PROD";
         $strQty = $strQty + "&quantity=" + $nQty;


       }
       else
       {
         $strQuery = $strQuery + "&promoteContractId" + $n - 1 + "=" + trim($plimus_code[i]) + "&promoteContractFlag" + $n - 1 + "=Y&addPromoteContract"    + $n - 1 + "=Y";
   $strQty = $strQty & "&promoteQuantity" + $n - 1 + "=" + $nQty;
       }
       $n = $n +1;
    }

  }
?>

Open in new window

0
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 500 total points
ID: 36586128
OR Try this...

Below is link to convert asp script to PHP. (You need register first)
http://www.design215.com/toolbox/translator/index.php


for ($i=0; $i<=8; $i++) {
			$nQty = CInt(explode( ",@$_POST["plimus_prod"])($i));  //Wenn die Anzahl größer als 0 ist
 
			if ($nQty > 0) {
				if ($n == 0) {
					$strQuery = $strQuery."contractId=".trim(explode( ",@$_POST["plimus_code"])($i)).".numberOfPromotionContract=TOTAL_PROD";
					$strQty = $strQty."&quantity=".CInt(explode( ",@$_POST["plimus_prod"])($i));
				} else {
					$strQuery = $strQuery."&promoteContractId".$n - 1."=".trim(explode( ",@$_POST["plimus_code"])($i)).".promoteContractFlag".$n - 1."=Y.addPromoteContract".$n - 1."=Y";
					$strQty = $strQty."&promoteQuantity".$n - 1."=".CInt(explode( ",@$_POST["plimus_prod"])($i));
				}
 
				$n = $n + 1;
			}
		}
		
		$strQuery = str_replace( "TOTAL_PROD", $n,$strQuery).$strQty;

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 36590761
If you're a competent programmer in ASP it will be easy to pick up PHP.  Get this book - it will get you set on the right path.
http://www.sitepoint.com/books/phpmysql4/
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now