Posts Tagged ‘array’

recursive function getting parent child A recursive function is a function that calls itself during its execution. This enables the function to repeat itself several times, outputting the result and the end of each iteration. function categoryChild($id) { $s = “SELECT ID FROM PLD_CATEGORY WHERE PARENT_ID = $id”; $r = mysql_query($s); $children = array(); if(mysql_num_rows($r) […]

get attribute of xml in php

Posted: 19th June 2012 by urfusion in php
Tags: , , , , , ,

get attribute of xml in php this is the attribute structure of xml [ForecastDay0] => SimpleXMLElement Object ( [@attributes] => Array ( [FDay] => 0 [Date] => 2008-11-11T00:00:01.930 [Name] => Tuesday ) And this is the code to retrieve attribute foreach($xml->Forecasts->$weather->attributes() as $a => $b) { $FDay = $b; } echo “$FDay”;

check database for array of values

Posted: 8th February 2012 by urfusion in php, Uncategorized
Tags: ,

check database for array of values example:UPDATE tableName SET someColumn = “updated” WHERE id IN(1, 88, 99, 152) so it can be done by for($i = 0; $i < count($arrayOfIDs) $i++) { if($i == 0) $concatenatedIDs .= $arrayOfIDs[$i]; else $concatenatedIDs .= ‘,’ . $arrayOfIDs[$i]; } $query = ‘UPDATE tableName SET someColumn = “updated” WHERE id […]