We help IT Professionals succeed at work.

Convert FOREACH loop from PHP to ASP.NET

narmi2
narmi2 asked
on
Does anyone know how to write the following PHP in ASP.NET(VB.NET)?

foreach ($_GET['listItem'] as $position => $item) :  
  $sql[] = "UPDATE `table` SET `position` = $position WHERE `id` = $item";  
endforeach;  

The data in $_GET['listItem'] looks like this:

item[]=1&item[]=2&item[]=3
Comment
Watch Question

Top Expert 2010
Commented:
Commented:
$_GET is replaced in asp by using  request.querystring("stringname") this will retrieve any information that is in the url as opposed to request.form which can retrieve posted form information.

Remember that all asp code must have <% and %> tags around it.

The sql statement could be something like sql = "Update 'table' Set 'position' = "+aspvariable+" where 'id' = "+aspvariable+""

when putting asp variables into a sql statement you must close the speech marks and then +variable+ then reopen the speechmarks to add more sql.

You could use a while loop for this also .

Hope this info helps

Author

Commented:
I'm lost completely.