Jump to content

aschk

Staff Alumni
  • Posts

    1,245
  • Joined

  • Last visited

    Never

Everything posted by aschk

  1. Ah yes, i didn't see that before...
  2. True, I was just mooching over the possible advantage that one might gain from chaining. It also occurs to me there potential for a greater loss here, because those functions can ONLY ever return $this (or a reference to another object), so you're negating any other return values. Fine of course if you don't need them
  3. Edited See ravenstar's post, if it isn't true it's going to be false
  4. Ok, so what do you want "&" or "&" ?
  5. Try and avoid the use of DISTINCT in SQL. Your query: SELECT DISTINCT report.id AS 'ID' , report.date_when , division.name , report.head_host , report.category FROM report, division WHERE report.date_when BETWEEN CAST('" . $start_date . " 00:00:00' AS DATETIME) AND CAST('" . $end_date . " 00:00:00' AS DATETIME) ORDER BY report.date_when DESC What is the DDL for your table (do SHOW CREATE TABLE <tablename> , for report and division). Also you're doing an inner join based on NOTHING, so for EVERY row in report you are joining to EVERY row in division. What is the key between reports and divisions? i.e. what links them? Give me this and you have your answer.
  6. isset returns a boolean value does it not, so if $_POST['keepimage1'] IS set then $image1check will equal TRUE, and vica versa for NOT set. So BOTH your if statements fail...
  7. Ooh and if you could provide an expected resultset with your sample data that would be even better. I think there's a good possibility you can do it with a single SQL line.
  8. You might to try indenting your code once in a while so that you can see your bracket matches... I don't think anyone can is going to be bothered with counting up the {} for you
  9. Try this : <? // Recursive pyramid function. function uplinePyramid($upline){ // Array of data. $data = array(); // Grab all the game cards. $result = mysql_query("SELECT * from gamecard WHERE Serialnum = '{$upline}' ORDER BY serial"); // Have we got any results? if(mysql_num_rows($result) > 0){ // Build dataset. while($row = mysql_fetch_assoc($result)){ $data[] = $row; } } else { // Return from this function // i.e. no more upline??? return; } foreach($data as $d){ insertGptran($d['Upline']); uplinepyramid($d['Upline']); } } function insertGptran($upline){ // Insert info. $sql = "INSERT INTO gptran(GpTID) VALUES($upline)"; mysql_query($sql); } ?> Obviously you still need to define the initial upline/serial, and it recurses as you want. Now i'll take a look at your table. Any chance of some sample data?
  10. Try explaining what you're trying to do in english (no code). Because i have a funny feeling that you can do what you want in a few lines with no recursion.
  11. You need to create arrays of the data before passing onto further calculations, and definitely don't use loopback (recursive) functions if you can avoid it.
  12. Can you elaborate on my test example then using array_multisort so that I may see a working solution. Also, yes you're correct you could interchange numeric values with the names, however where do you change the numbers for their string representations? PHP Constants? They lose their meaning if you just use numbers, hence the extra table requirement. Of course you could just interpret those numeric in PHP, but with what? Constants? Is it maintable, nope Of course at the end of the day, each person's choice is there own and i'm sure gin will find an applicable solution be it one of ours or not. All are valid, and i'm certainly not trying to preach or control any particular channel of thinking on the matter. Just trying to offer another solution, with drawbacks/pitfalls and all. I will continue to be a PHP pest until I can't see the faults in others and my own designs
  13. Because you're performing another query inside the loop that uses mysql_fetch_array...
  14. That's the PEAR library right? You can just install it in your directory (if it's not available already, on the server) and then use ini_set("include_path", <path here>) to set the path to the PEAR directory. Might be worth outputting ini_get("include_path") to see what you have already.
  15. For any more object oriented help try the specific OOP help part of the forum. I like hanging around there
  16. Nice variation on my solution Barand I should just explain the reasoning behind my solution better : Your SQL statement doesn't change if you add another category, where as in Barand's example you need to alter your SQL statement. Mine would be ORDER BY award_category.`order` no matter how many categories you have. Also, Barand's option provides no referential integrity for your data, meaning you could have "Finalist" , "finalist", "finlist", or some other horrid variation your input.
  17. Do you know what that script you have does? It sends an email... So if you have : $email = "stupid@girl.com"; NO-ONE can see that. It's a PHP variable, it never gets displayed (unless you echo it, which really would be stupid).
  18. You're outputting more than 1 form, you only need 1 form... Also where are the input fields with the names of the photos? Seriously use my nice simple example, make a simple script using the html i have given you, submit it to the php page i have given you and learn what it's doing. Then apply the same logic to your complex script. Incidently i recommend separating out your logic better, keep your presentation and business logic apart.
  19. Okey dokey, having taken your example toon i've written it out a little further with some sample data. This is what i'm after... All the awards for the year 2007, ORDERED as gold, then silver, then bronze, then finalists... <?php $array = array ( 'award' => array ( 'Finalist - Public Service Messages and Cause Appeal Category', 'Finalist - Private Death Camp Service in Guantanamo', 'Finalist - 3rd post', 'Silver - ertae aerg aer g', 'Gold - lkerjgklaejr arar', 'Bronze - el;araek lrjlkrja', ), 'year' => array ( 2006, 2007, 2007, 2007, 2007, 2007, ) ); $findyear = array_keys($array['year'], 2007); for($i = 0; $i<count($findyear); $i++){ echo $array["award"][$i]."<br/>"; } ?> What we have in the above a list of awards... fantastic, but how do you order then??? I think you've missed the point of the question. I'm going to propose that your database structure could use some modification gin. You need a separate field for "position" with it being "gold", "silver", "bronze", or "finalist" linked by another table, with an "order" column also. Thus you can have Award_Types #################### id | type | order ==================== 1 | gold | 1 2 | bronze | 3 3 | finalist | 4 4 | silver | 2 Now should you ever have another position (platinum) you just add it in at the bottom and rejig your ordering, AND voila your SQL statement will STILL continue to order by the order in the table.
  20. Your next question is going to be how do i submit that through a form : Your html <input type="text" name="photos[]" /> <input type="text" name="photos[]" /> <input type="text" name="photos[]" /> Your php <? $arrayOfFiles = array($_POST['photos'][0],$_POST['photos'][1],$_POST['photos'][2]); foreach($arrayOfFiles as $file){ unlink($file); } ?>
  21. Try : $arrayOfFiles = array("nameoffile","nameofnextfile","nameoflastfile"); foreach($arrayOfFiles as $file){ unlink($file); }
  22. Don't use ob_start unless you ABSOLUTELY have to. My question is why are you trying to output something to a page which won't even get shown if you're redirecting.... Those echo's should never occur, no-one will ever see them.
  23. I was about to ask what $cmd was....
×
×
  • 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.