Error
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.

foreach

Delete all the files in specified directory in asp.net
Monday, 30 January 2012 07:58
// Delete all the files in specified directory in asp.net


private void DeleteAllFilesInMyDirectory(string MyDirectoryPath)
{
if (Directory.Exists(HttpContext.Current.Server.MapPath(MyDirectoryPath)))
{
string[] filenames = System.IO.Directory.GetFiles(HttpContext.Current.Server.MapPath(MyDirectoryPath));
foreach (string filename in currntDirectoryFilenames)
{
File.Delete(filename);
}
}
}

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/KSGYh5pM1cI/14555

 
Delete all the files in directory in asp.net
Friday, 27 January 2012 10:43
// Delete all the files in directory in asp.net



private void DeleteDirectoryFiles(string path)
{
if (Directory.Exists(HttpContext.Current.Server.MapPath(path)))
{
string[] files= System.IO.Directory.GetFiles(HttpContext.Current.Server.MapPath(path));
foreach (string file in files)
{
File.Delete(file);
}
}
}

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/2XpiqY5IMtY/14479

 
Set attribute of all fields in Symfony Form
Sunday, 09 May 2010 13:11
// description of your code here

[code]
class ClientForm extends BaseClientForm
{
public function configure() {
$fields = $this->getWidgetSchema()->getFields();
foreach ($fields as $f) {
$f->setAttribute("class", "client_form_field");
}
}
}
[/code]

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/3E6JcVhzpcY/11303

 
Insert into a table from a foreach loop
Tuesday, 02 March 2010 21:22
// description of your code here




$_SESSION['order_id'] = mysqli_insert_id($conn);

//This is adding any additional contact numbers to the contact_numbers table if the user added additional contact numbers
if($_SESSION['contact']) {
foreach ($_SESSION['contact'] as $counter => $contact_array) { //This specifies the $_SESSION['order'] array to loop through
foreach ($contact_array as $key => $value) { //This specifies the array within the $_SESSION['order'] array
$extra_number[$counter][$key] = $value;

$contact_sql = 'INSERT INTO contact_numbers (order_id, contact_type, int_prefix, prefix, first, last) VALUES (?, ?, ?, ?, ?, ?)';

$type = $extra_number[$counter]['additional_contact'];
$int_prefix = $extra_number[$counter]['additional_int_prefix'];
$prefix = $extra_number[$counter]['additional_prefix'];
$first = $extra_number[$counter]['additional_first'];
$last = $extra_number[$counter]['additional_last'];


if($stmt->prepare($contact_sql)){

$stmt->bind_param('isiiii', $_SESSION['order_id'], $type, $int_prefix, $prefix, $first, $last);
$contact_done . $counter = $stmt->execute();
}

} //end foreach
} //end of outer foreach loop
}//end if session[contact]





Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/jE-pt7ujqZ8/10381

 


Taxonomy by Zaragoza Online