Jump to content

RussellReal

Members
  • Posts

    1,773
  • Joined

  • Last visited

Everything posted by RussellReal

  1. okay... <?php $list = array(); $list[] = array('2008-01-01','120.00',''); $list[] = array('2008-02-09','','120.00'); $list[] = array('2008-01-01','','80.00'); // initial sorting loop.. $dates = array(); foreach ($list as $v) { if (!isset($dates[$v[0]])) { // if $dates['2008-01-01'] isn't set.. $dates[$v[0]] = array(); } $dates[$v[0]][] = array($v[1],$v[2]); } // once its all sorted BY DATE $oneLines = array(); foreach ($dates as $date => $array) { $actual = 0; $budget = 0; foreach ($array as $v) { $budget += $v[0]; $actual += $v[1]; } $oneLines[] = array($date,$budget,$actual); } print_r($oneLines); ?>
  2. You could query for subcategories.. or.. 'forums' and then in the query run a subquery to gather the catid's name counterpart.. e.g. "SELECT (SELECT name FROM categories WHERE id = catid) As categoryName" so the entire query will look something like this.. "SELECT (SELECT COUNT(*) FROM Posts WHERE forumid = Forums.id) As posts, (SELECT name FROM Categories WHERE id = Forums.catid) As categoryName FROM Forums" THAN you loop through them.. seperate them by categoryName.. and then put them into their places.. Goodluck
  3. syntax for a query which will insert MULTIPLE rows would be like: INSERT INTO table (field1,field2,field3) VALUES(a,b,c),(d,e,f),(g,h,i) now.. if you want to do this in a LOOP.. you could try something like this: $rows = array(); while (whatever) { $values = array(); $values[] = '\'field1ValueforThisResult\''; $values[] = '\'field2ValueforThisResult\''; $values[] = '\'field3ValueforThisResult\''; $rows[] = "(".implode(',',$values).")"; } mysql_query("INSERT INTO table (field1,field2,field3) VALUES".implode(',',$rows));
  4. so you would like it to.. A) Add up all the budgets from same day.. and B) add up all the actuals from the same day.. than C) make it show the totals in each slot?
  5. imagestring
  6. I just tried to write up a script to do this and ran into two possible road blocks, CURL_PUT doesn't allow you to send a form field name to go along with the file pointer, unless I'm mistaken, and I did some googling and cURL's @filename doesn't exactly work thru php. hope sum1 else can give you a better answer.
  7. sorry.. theres a mistake in my code above and I can't modify <?php $gene1 = 'aaBb'; $geneA = array(); $i = 0; while ($i < strlen($gene1)) $geneA[] = substr($gene1,$i++,1); $gene2 = 'Aabb'; $geneB = array(); $i = 0; while ($i < strlen($gene2)) $geneB[] = substr($gene2,$i++,1); $possabilities = array(); foreach ($geneA as $A) { foreach ($geneB as $B) { if ($A === strtoupper($A)) $possabilities[] = $A.$B; else { if ($B === strtoupper($B)) $possabilities[] = $B.$A; else $possabilities[] = $A.$B; } } } ?>
  8. each gene usually comes in pairs of two.. like Bb or bb or BB.. so lets say you cross Bb with bb, but if you have like you said aaBb than you'd need to go into more detail.. this should cross any number of genetic traits across itself then you just randomly pick from $possabilities all you need to do is simply <?php $gene1 = 'aaBb'; $geneA = array(); $i = 0; while ($i < strlen($gene1)) $geneA[] = substr($gene2,$i++,1); $gene2 = 'Aabb'; $geneB = array(); $i = 0; while ($i < strlen($gene2)) $geneB[] = substr($gene2,$i++,1); $possabilities = array(); foreach ($geneA as $A) { foreach ($geneB as $B) { if ($A === strtoupper($A)) $possabilities[] = $A.$B; else { if ($B === strtoupper($B)) $possabilities[] = $B.$A; else $possabilities[] = $A.$B; } } } ?> and $possabilities SHOULD hold all 4 possabilities if I did that right.. the above is not tested..
  9. no... just programmers seperate regular php files.. from class or library php files.. if you're making the php file JUST for a class.. for your own future ease.. you'd name it XXXX.class.php or class.xxxx.php or w.e and some peopl ename it lib.xxx.php or xxx.lib.php for libraries of functions.. its just a programming method
  10. because once the php interpreter exits you can no longer use php.. so when the user actually sees the link.. it is already too late, you CAN however create an AJAX function to connect to a PHP file on your server than that php script sets the session var.. google AJAX
  11. [quote author=Pig link=topic=267295.msg1260742#msg1260742 Thanks, but I'm after some code that will compare to numbers in a list, such as [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]. So for example, if the number is 56, the answer will be 20? yes.. that is what you wanted is it not? and if the number is 56... and two people answered 55 and 57.. who should win.. lower or higher?
  12. fileatime last time it was accessed... filectime creation time filemtime last modified time
  13. while (($rand = rand(1,655)) == 300) { // do nothing.. } // $rand will never equal 300.. lol
  14. <?php function checkForHttp($a) { if (strpos($a,'http://') !== false) { $a = 'http://'.$a; } else { if (strpos($a,'https://') !== false) { $a = 'http://'.$a; } } return "<a href='{$a}'>{$a}</a> "; } $tld = array('com','co.uk','tk','net','org','biz','tv','me','info'); preg_replace("/((?:https?:\/\/)?(?:[a-z0-9-]\.)*".implode('|',$tld).")\s/ie",'checkForHttp(\'$1\')',$text); ?>
  15. first part.. frames or ajax.. ajax would be a bit more tricky tho considering if you're gonna do page refreshes it could be a lil tricky with serverside code.. like working with sessions coz then you'd hafta do EVERYTHING before outputting ANYTHING.. and you can't code like normal lol its hard well not HARD but tedious and the second bit.. I'm not sure if there is an open source script for that.. but you could code one relatively easy.. well I could
  16. well if you use sessions than its easier coz then you'd just loop thru the files and work with the last modified time on the session file and work within a reasonable timeframe as to what 'recent' would be considered.. maybe 15 minutes? 20 minutes? and then just put the session filenames into an array.. shuffle the array, then array_pop the array 5 times..
  17. you would need to work with a credit card merchant like paypal is a gateway which works with merchants for you.. and than you'd have to use their APIs to process payments instantly
  18. not from what is shown... there is most likely some sort of a loop surrounding it all.. because than there is absolutely no reason to add the crlf at the end anyway.. in your case he doesn't even need to USE rtrim() he would just remove ."\r\n" lol
  19. the reason ignace's example would work is because you are trying to go into an instance, where as he is looking inside the class model, also you used define() which would go into the global scope rather then the object's scope, also.. You're defining it inside a function which requires a process to define.. which than isn't findable within the original class model. :: looks into the original model of the class.. -> looks into an instance of that class
  20. you'd have to put it ALL into $buffer before you put it into the file.. to have rtrim() work correctly in this scenario
  21. idk about your problem but like.. I see two ISSUES right here $sql = "SELECT * FROM disable"; $result = $database->query($sql); $row = mysql_fetch_array($result); if(($user == $row['user']) && ($row['disabled'] != 0)){ header("Location: http://members.aerialfusion.co.uk/index.php?disabled=".$user."&by=".$_SERVER['REMOTE_ADDR']); } the query will pull ALL results from the database.. THEN pull the first result from the resultset then the if statement will check if the user is the FIRST result in the table.. which is not very secure if you disabled an account and he is the SECOND result.. you should use a WHERE clause in the query.. SELECT * FROM disable WHERE user = '$user' the SECOND issue there is.. header("Location: http://members.aerialfusion.co.uk/index.php?disabled=".$user."&by=".$_SERVER['REMOTE_ADDR']); the Location header needs a valid url.. ........ is not a valid url.. and your whole detirmination process is redundant.. you should do something like this: <?php $s = "SELECT * FROM personal WHERE user = '{$user}' AND password = '{$pass}'"; $r = $database->query($s); if ($z = mysql_fetch_assoc($r)) { // if user and password were correct.. if (!$z['active']) { // if user is not active } else { // log the user in.. } } else { if ((!strlen($user)) || (!$strlen($pass))) { // form was not filled out fully } else { // invalid username and password } } ?>
  22. u dun really hafta use an anchor.. u could use javascript inside the href.. but if you want to use an anchor you'd use onclick="" inside the <a> tag.. but if you want to do like js in the href u just do <a href="javascript:code.to.do('when',CLICKED);">NO</a>
  23. you mean you want to make thumbnails? imagecopyresampled
  24. #1 you're trying to compare 'lady1' as a string NOT a constant to the $username variable which means you should encase that string with quotes.. #2 when a user logs in you should store their username and other often used information in a session... so if you do store them in a session if ($_SESSION['username'] == 'lady1') { }
  25. I can't DO it for you, however, look into 'LIMIT' in mysql
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.