hi, can some please tell me what's wrong with the bellow foreach php loop.
foreach ($_POST[sortlist] as $key => $value)
{
$sql = "UPDATE sortable
SET color_order = " . mysql_real_escape_string($key) . "
WHERE id = " . mysql_real_escape_string($value);
$result = mysql_query($sql) or die(mysql_error());...
I have a PHP Object which contains other objects
i.e
$obj->sec_obj->some_var;
I want to use a foreach loop to loop through the object and all objects objects. I think the max level is 3, so
$obj->sec_obj->third_obj->fourth_obj
Any ideas?
...
Since C# doesn't have a before,after,last,first etc. as part of its foreach. The challenge is to mimic this behavior as elegantly as possible with the following criteria:
Must allow: before, first, even, odd, last, after events
Give an option execute/not execute the primary function (function executed on all objects of the collection) ...
Hello my kind sirs. (lol)
I have a panel on Form1.
I'm going to add several instances of my custom usercontrol MovieItem to that panel.
To do this I'm going:
panel1.Controls.Add(objMovieItem);
Now, within the MovieItem.cs code I'm adding the .Click events of everything inside the UserControl so that whenever a user clicks ANYWHERE i...
Suppose the following code:
foreach(Item i on ItemCollection)
{
Something s = new Something();
s.EventX += delegate { ProcessItem(i); };
SomethingCollection.Add(s);
}
Of course, this is wrong because all the delegates points to the same Item. The alternative is:
foreach(Item i on ItemCollection)
{
Item tmpItem = i;
Som...
I try to do the following:
QList<QString> a;
foreach(QString& s, a)
{
s += "s";
}
Which looks like it should be legitimate but I end up with an error complaining that it cannot convert from 'const QString' to 'QString &'.
Why is the QT foreach iterating with a const reference?
...
Hi All,
Can anybody who has worked on XSLT help me on this?
I am using XSL version 1.0.
I have declared a parameter in XSL file like:
<xsl:param name="HDISageHelpPath"/>
Now I am assigning the value to this parameter from an asp page . The value which I assign is "document('../ChannelData/Sage/help/ic/xml/HDI.xml')/HelpFiles/Help"....
Here's the code I have:
private void ClearSearchResults()
{
foreach (Control X in panel1.Controls)
{
panel1.Controls.Remove(X);
}
}
The problem is, when I run this method, only a single item is deleted, then if I click on a button again so the method can run again, another is deleted.
If I ...
I have this code (C#):
using System.Collections.Generic;
namespace ConsoleApplication1
{
public struct Thing
{
public string Name;
}
class Program
{
static void Main(string[] args)
{
List<Thing> things = new List<Thing>();
foreach (Thing t in things) // for each fil...
In the following code, How can I pass the type of variable to the nested foreach statement?
getControls is a recursive function that returns a list of controls (wow!)
getControls(String type, Control donde)
var tipos = new List<Type>() { typeof(Button), typeof(KryptonTextBox) };
foreach (Type t in tipos)
{
List<Control> controls ...
Hi,
In Java, a for-each loop.
If I have a method that generates an array, called genArray().
In the following code, will the array each time be re-generated by calling genArray()?
Or will Java call once the method and store a copy from the array?
for (String s : genArray())
{
//...
}
Thanks
...
I'm using VS2008.
Is the following OK to do the following VB.NET with a very simple class (see below)?
for each CurrentObject as MyObject in MyArray
'access current object
next
The "simple class":
Class MyObject
public I as integer
end class
I seem to remember that something about needing iEnumerable, but my compiler isn't com...
I know I'm missing something here. In the XSLT transformation below, the actual result doesn't match the desired result.
Inside the for-each, I want to apply the match="track" template to each selected track element. If I've understood XSLT properly, with the current setup only child nodes of each selected track element are matched agai...
It's been a while since Visual Studio added support for a foreach extension that works like
vector<int> v(3)
for each (int i in v) {
printf("%d\n",i);
}
I want to know how to make any class able to use foreach. Do I need to implement some interface?
...
Suppose I have the following code:
foreach(string str in someObj.GetMyStrings())
{
// do some stuff
}
Will someObj.GetMyStrings() be called on every iteration of the loop? Would it be better to do the following instead:
List<string> myStrings = someObj.GetMyStrings();
foreach(string str in myStrings)
{
// do some stuff
}
?
...
HI!
My XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<Dokument>
<Skupina id="3">
<Naziv_skupine>RAZSTAVNI PROSTOR</Naziv_skupine>
<Dvorana id="295">
<Naziv_dvorane>DVORANA C</Naziv_dvorane>
<Postavka id="41">
<Artikel>1105</Artikel>
</Postavka>
...
I'm trying to loop through the results of a function that is returning an anonymous object of results.
public static object getLogoNav()
{
XDocument loaded = XDocument.Load(HttpContext.Current.Request.MapPath("~/App_Data/LOGO_NAV_LINKS.xml"));
var query = from x in loaded.Elements().Elements()
select new
...
I have a for-each and when there is nothing output by it I would like to display some default text.
If I have...
<xsl:for-each select='xpath'> Some content for each matching element result. </xsl:for-each>
What I would like is:
<xsl:for-each select='xpath'>
<xsl:output-this-when-there-is-content> Some content for each matching el...
How can i array a string, in the format that $_POST does... kind of, well i have this kind of format coming in:
101=1&2020=2&303=3
(Incase your wondering, its the result of jQuery Sortable Serialize...
I want to run an SQL statement to update a field with the RIGHT side of the = sign, where its the left side of the equal sign? I know ...
I’m trying to write my first script to search for a given pattern in text file named test. Here is the script:
#! /bin/csh
echo -n "enter pattern: "
set pattern = $<
foreach word (`cat test`)
echo $word | egrep $pattern
end
When I try to run it I get the message foreach: No match found. I suspect the problem is ca...