Jump to content

gin

Members
  • Posts

    82
  • Joined

  • Last visited

    Never

Everything posted by gin

  1. The way I'd do it is to place all the fields into an array, then use a foreach to generate the query. I don't know if there's a way to seach rows like what you suggest.
  2. I'm not sure about the headers, but I know some hostings don't allow more than x number of mails sent out per hour, in an attempt to cripple spammers.
  3. Do an if to check if it's the last row. Use mysql_num_rows
  4. *winces* well that's your perogative, really. I just hope for your sake you don't have to add users or change their colours too often. As for the date... I'd suggest you test it out around Dec 31, Jan 1. I suspect you'll be very unhappy with the result. I reiterate, strtotime().
  5. <form method="post" action=""> <input type=hidden name=max value=3000> <input type=text name=current> <input type=submit name=submit value=submit> </form> Then at the top, before the thermometer is displayed (probably at the very very top of the page): if ($_POST['submit'] == 'submit') $current = $_POST['current']; This should bypass the need for the URL variables.
  6. you want to read the text drawn in an img file? I think you've ventured out of PHP and into OCR. Can't you transfer the text some other way? The filename at least, if for some reason plain old variable won't swing it.
  7. It'd be great if you could explain what you mean by "sum up the columns into 2 separate fields". Also, please cut out all non-relevant code.
  8. First, I'd advise you to use CSS, since <font> is depreciated. It'll make dealing with the colors and other formatting much much easier. Next for comparing dates, change the the date into a timestamp with strtotime(). After that, I'm pretty sure you'll be able to figure things out.
  9. Your code is riddled with basic errors. You really need some kind of text editor with color formatting. I suggest Notepad++. Now, as for your code, the two lines you should look at: <?php //echo " $stat "; //"; what's this? the // comment only comments one line if ($i = 0; $i <= 5; $i++) // and this? this is either a for loop or should be commented out. ?> There are probably more, but this should start you out.
  10. Firstly, you forgot to echo your text, so of course nothing is showing. Also, wouldn't it be easier to substr() what you need off the variable before you compare? <?php $x = substr ($Education1, 0, 7); if ($x <> 'English') echo 'whatever'; ?>
  11. In the end I added a sort field to the db. This way I can leave all the sorting to MySQL. Note to self: plan better.
  12. Thank you everyone for all your suggestions. Right now, for the sake of expediency, I'm using nested loops, but I'm certainly interested in learning how to work smarter. @ToonMariner: Your solution is definitely close to what I'm looking for, assuming I can wrap my brain around the array_multisort(). I need to go tinker with my code and try out Barand's code. @Barand & aschk: I did in fact consider separating the award and category into different fields. Unfortunately, the awards aren't so cooperative as to have plain old "gold, silver, bronze" awards. It varies from Gold to Gold World Medal to Winner to.... you get the idea. Frankly, I should have just added another field, "sort_order", or similar. This is what I get for not planning things out properly.
  13. The array is actually generated from a database. All items have the same fields, so that's not an issue. The second post is my attempt at a brute force method of sorting (if it can be called that). It's just the same information placed in the order I'll eventually want to display it in. The display, incidentally, will look something like: Some Award - Gold - Bestest in the world Title: asdf asdf (2006) - Finalist - PSA Title: qwer qwer (2006) Some Other Award - Gold - Bestest in the world Title: asdf asdf (2006) - Silver - PSA Title: qwer qwer (2006) Anyway, I'm kinda resigned to the foreach-ksort method at the moment. I was just hoping someone knew of a sort I'd never heard of that would do all I want without the gazillion loops.
  14. Thanks very much for your reply! Your code piece makes no sense to me, but if I'm reading the explanation correctly... well this is my attempt: <?php Array ( [some Award] => Array ( [4] => Array ( [0] => Array ( [award] => Finalist - PSA [year] => 2006 [name] => Some Award [project] => 20 ) ) ) [some Other Award] => Array ( [4] => Array ( [0] => Array ( [award] => Finalist - PSA [year] => 2006 [name] => Some Other Award [project] => 26 ) [1] => Array ( [award] => Finalist - yadda yadda [year] => 2007 [name] => Some Other Award [project] => 26 ) ) [1] => Array ( [0] => Array ( [award] => Gold - Animation [year] => 2006 [name] => Some Other Award [project] => 4 ) ) ) ) ?> Now however, to my utter annoyance, the Finalists are listed before the Gold. Is there any way to use array_multisort to sort according to keys, or should I just give in and foreach-ksort my way through?
  15. This has been giving me SUCH a headache I have an array like so (of course, there are many more items than shown): <?php Array ( [0] => Array ( [award] => Finalist - Public Service Messages and Cause Appeal Category [year] => 2006 [name] => Big Huge Award [project] => 20 [section] => animation [brand] => asdf [title] => Funky title ) ) ?> I want to sort it by [award] in this order: Gold, Silver, Bronze, Finalist. I'm getting nowhere with uksort. The problem is the callback function. So far I've got: <?php function cmp($a, $b) { $sortorder = array('gold', 'silver', 'bronze', 'finalist'); if ($a['position'] == $b['position']) return strcmp($a['name'], $b['name']); $cmpa = array_search($a['position'], $sortorder); $cmpb = array_search($b['position'], $sortorder); return ($cmpa > $cmpb) ? 1 : -1; } ?> I need to modify this so that the keywords 'gold', 'silver', etc. are picked out of the long [award] field. Could someone point me on my way?
  16. In the block of code that starts: if( isset($_POST['action_signup'])) { You'll note that if it passes the security_code, nothing happens and your code proceeds onwards. But if it fails, then it prints the error message, then still proceeds onwards. You need to enclose the db insertion, etc. into your if-else statement.
  17. I was using FF1.5. Actually I think it had nothing to do with the browser and all to do with the Free Download Manager that was downloading the file. Once I disabled it, the variables came thru fine. Thanks for all the help, guys!
  18. gin

    target

    I don't really understand. If it opens the correct window in the correct frame, what's the problem? Are you saying a new page autoloads as well? In that case I'd look at index.php to see if there's any javascript which might cause this.
  19. I suggest this tutorial for database connection: http://www.phpfreaks.com/tutorials/142/0.php The query to get the most recent row of data would be: SELECT * FROM b LIMIT 1 The MySQL & PHP manuals are invaluable resources.
  20. That doesn't work for me. The resultant file has the wrong filename (test.php instead of file.csv) and the contents are only the <form>...</form>, even when I placed the form in the else portion of that if statement. I'm using Apache 2, PHP 5, MySQL 5, if it's relevant.
  21. If I do the following it works as expected. The variable $foo is passed from the form correctly. <?php echo '"aaa","bbb"'; $out = "\n\"".$_POST['foo'].'"'; print $out; ?> However, in the following the variable doesn't pass at all. The CSV file comes out okay, but where the variable should be there is nothing. <?php header("Content-type: application/csv"); header("Content-disposition: attachment; filename=file.csv"); echo '"aaa","bbb"'; $out = "\n\"".$_POST['foo'].'"'; print $out; ?> Any advice much appreciated, for the sake of my remaining hair.
  22. [quote author=letmein link=topic=116535.msg475389#msg475389 date=1164756562] lol, thanks all, I will look into the Load Data Infile thing, I dont know if it can go without formatting the csv file first though as some of the fields dont have the remaining ,'s at the end, so I would have to do something like a loop to add the missing number of commas, if the field count is lower than the required field count would I??? or would it work without having to add these please? [/quote] I'm pretty sure once it reaches an end of line, it'll go to the next row and just assume the rest of the fields are blank. Like I said, I suspect you don't have to do any PHP editing at all. I think you don't even have to unzip the file for it.
  23. What do you need the YES for? You should be doing something like this: [code]<?php $max = sizeof($checkboxArray); for($counter=0; $counter<$max; $counter++) { if ($checkboxArray[$counter] == true) echo '<input type="checkbox" checked>'; else echo '<input type="checkbox">'; } ?>[/code] Remember that array indexes start at 0.
×
×
  • 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.