-
Posts
271 -
Joined
-
Last visited
Everything posted by blacknight
-
you have to escape your " inside " when echo in an echo statement
-
this si smaller and a lil simpler... note the 3 line xml -> php array converter... $xml = new SimpleXMLElement('teams.xml',NULL,true); $json = json_encode($xml); $array = json_decode($json,TRUE); echo '<pre>'; echo 'Befor<br>'; print_r($array); echo 'After<br>'; sksort($array,'overallpoints'); print_r($array); function sksort(&$array, $subkey="id", $sort_ascending=false) { if (count($array)) $temp_array[key($array)] = array_shift($array); foreach($array as $key => $val){ $offset = 0; $found = false; foreach($temp_array as $tmp_key => $tmp_val) { if(!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) { $temp_array = array_merge( (array)array_slice($temp_array,0,$offset), array($key => $val), array_slice($temp_array,$offset) ); $found = true; } $offset++; } if(!$found) $temp_array = array_merge($temp_array, array($key => $val)); } if ($sort_ascending) $array = array_reverse($temp_array); else $array = $temp_array; }
-
//sksort($abs); you did not state the array key to sort by you have to include the ,'overallpoints' or the function does nothing
-
move $rowyp = mysql_fetch_assoc($resultyp) out of the while statement and vardump $rowyp and see what it says and post it... other then that i dont see any thing that stands out...
-
if your using all the firnds in a table yes if not .. then no if i only need 5 out of say 15 foelds i state eacj if i need them all i use *
-
this is a function i use to sort my arrays [code function sksort(&$array, $subkey="id", $sort_ascending=false) { if (count($array)) $temp_array[key($array)] = array_shift($array); foreach($array as $key => $val){ $offset = 0; $found = false; foreach($temp_array as $tmp_key => $tmp_val) { if(!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) { $temp_array = array_merge( (array)array_slice($temp_array,0,$offset), array($key => $val), array_slice($temp_array,$offset) ); $found = true; } $offset++; } if(!$found) $temp_array = array_merge($temp_array, array($key => $val)); } if ($sort_ascending) $array = array_reverse($temp_array); else $array = $temp_array; } sksort($yourarrayname,'overallpoints'); and its done no need to make the assign the array to a new var it keeps the old one
-
put <?php YOURAUTHCODEHERE ?> and html stays this waya php file will print html properly as long as it is not inclosed in code tags so your auth code can go in the top and stop the page load if the requirements are not meet
-
[ROOKIE] Terminology - need advice as to what this is
blacknight replied to nynnem's topic in PHP Coding Help
$_GET['id'] will retreve the song id from the url for you thats a big help there then its just a basic sql query to get the song by id and the relavent data and display it nothing complicated just simple is best lol -
http://www.daniweb.com/web-development/php/threads/129485 i guess its possable but i have never used it ....
-
with out using post with a submit you will have to supply username and password to the server and use fpt to automate any thing other wide your server will drop the upload
-
using gd in php loses the animation in gif images if i remember wright
-
its errorintg because $result just says weather the query worked or not run mysql_fetch_assoc( then count that
-
number_format(abs(($time1-$time2)/60/60), 2, '.', '') shold show hours...
-
yes but not all eamils are just i dot extention my old school one was @unb.nb.gc.ca .... on the php manual some one cretaed this function http://www.php.net/manual/en/function.preg-match.php#105542 looks complex but validates the entier address peace by peace
-
this is a simple fuction that will save the image to your server function save_image($inPath,$outPath) { //Download images from remote server $in= fopen($inPath, "rb"); $out= fopen($outPath, "wb"); while ($chunk = fread($in,8192)) { fwrite($out, $chunk, 8192); } fclose($in); fclose($out); if (file_exists($outPath)) { return true; } else { return false; } }
-
preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $str); will match an email http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet-version-1/ this is a regex cheet sheet that i use explanes alot of stuff...
-
DzSoft_PHP_Editor is a decent one
-
function shutdown() { $included_files = get_included_files(); foreach ($included_files as $filename) { echo "$filename\n"; } } register_shutdown_function('shutdown'); and thats how its done the function will only run once the page pas finished all other functions its queued at the end of the process tree in php
-
yea i made an error in muy code lol change $query ."WHERE WorkGroupID = '".$branch."' AND"; to $query ."WorkGroupID = '".$branch."' AND"; then change ON tblleaveapplication.employeeid = tblemployee.id"; to ON tblleaveapplication.employeeid = tblemployee.id WHERE "; and as fopr the dropdown befor your while statement add <option value= "ALL" <? if ($branch=='ALL'){ echo 'selected'; } ?> >All Branches</option> and a side note dont use shorttags .. like <? it can lead to to issues with servers allways use <?php
-
i think i under stand try and fallow my example you ahve 5 people with grades john - 80 bob - 75 mike - 88 jan - 65 tom - 25 you want to run them throu the function to assign something like a gpa average based on a decimal system you are using? if so.. you need to make the marks an array and pass them through the function using a for statement ex $results=array(); foreach($marks as $student => $mark) { $results[$sutdent] = gpamark($mark); } then printing $results should have your numbers.. marks should appear like this $marks = array('john' => '80','bob' => '75','mike' => '88','jan' => '65','tom' => '25'); hope that helps a lil...
-
manualy add the select all branches to the dropdown list give it the value of all then this is where it gets a lil complicated this would be your new $query statement $query="SELECT *, MONTH(tblleaveapplication.DateFrom) as DFMonth, MONTH(tblleaveapplication.DateTo) as DTMonth, YEAR(tblleaveapplication.DateFrom) as DFYear FROM `tblleaveapplication` LEFT JOIN `tblemployee` ON tblleaveapplication.employeeid = tblemployee.id"; if ($branch != 'ALL') { $query ."WHERE WorkGroupID = '".$branch."' AND"; } $query ."( (MONTH(tblleaveapplication.DateFrom)=".$leavemonth." AND YEAR(tblleaveapplication.DateFrom)=".$leaveyear.") OR (MONTH(tblleaveapplication.DateTo)=".$leavemonth." AND YEAR(tblleaveapplication.DateFrom)=".$leaveyear.") )";
-
$included_files = get_included_files(); foreach ($included_files as $filename) { echo "$filename\n"; }
-
C:\wamp\www\include\parser.php im guessing has the parse_message function in it which is what you gave us in the pastbin file id like to see the s.php you may be redeclaring it and not relised it....
-
preg_replace('/^(.+)[\,]+([ \w]*)$/','\1\2',$e); shoudl do the trick will remove the last , in any statement
-
Need help with displaying MySQL data
blacknight replied to darkangel2001lv's topic in PHP Coding Help
you use the fallowing code to set the data returned as a object var example $data = mysql_fetch_array($result); then you can return the data as $data['item_code'] and so on and so on