Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. No worries. If you read the comments, you should follow. If you're all done, can you hit the topic solved button please?
  2. cURL is the way to go. Did you remember to set CURLOPT_RETURNTRANSFER to true?
  3. Well, you'll need to do a comparison then won't you? You'll need both times in the form of integers. So you'll have to use strtotime()/mktime() to convert your dates to unix timestamps. If you're trying to do it in a mysql query, use the mysql UNIX_TIMESTAMP() function. Perhaps if you explain your situation more fully, we'll be able to give you more help.
  4. Try this: <?php //define the xml standard header("Content-type: text/xml"); echo "<?xml version='1.0' encoding='ISO-8859-1'?>"; //this section calculates the image names in the directory $imgdir = 'img/'; // the directory, where your images are stored $allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show $dimg = opendir($imgdir); echo "\n<gallery> <image>\n"; $imgs = array();//create the blank array while($imgfile = readdir($dimg)) { if(in_array(strtolower(substr($imgfile,-3)),$allowed_types)) { $imgs[] = $imgfile;//add to the array in the loop } } sort($imgs); foreach($imgs as $img){//loop through the images to output them echo ' <url>img/' . $img . "</url>\n"; } echo ' </image> </gallery>'; ?>
  5. Just use strtotime()/mktime(). Then check to see if the returned integer is greater than time().
  6. I think what you wanted is something like the following, where you order by one field in the query, cycle through the results and only ouput that field if the value is different from last time the loop ran. $sql ="SELECT field1,field2,field3 FROM yourtable ORDER BY field1"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $prev = ''; while($row = mysql_fetch_assoc($result)){ if($row['field1'] != $prev){//the value has changed since last time the loop ran echo $row['field1'].'<br />'; $prev = $row['field1']; } echo $row['field2'].$row['field3'].'<br />'; } Bit difficult to give you anything more than that without more information.
  7. Sorry? Where's the array? What do you mean by 'pulled out on a page'?
  8. 1.) !> is not a valid comparison operator. Just use < (and vise-versa for the other comparison) 2.) You're missing an ORDER BY clause before you use RAND().
  9. You could read the file names into an array before sort()ing it.
  10. Is logic something you can really learn from a book?
  11. Looks more like a gimmick to me; i can't really see it being at all useful. Looks cool though.
  12. lol. A man after my own heart. Have you seen this?
  13. 1.) Well, you've not given your textfield a name. I assume it was supposed to be called search? : <input type=\"text\" value=\"{$_POST['search']}\" name="search" /> Without more info, that's about all i can suggest. What's the current output? 2.) Add an order by clause: $sql = "SELECT * FROM `ddoitems` WHERE `ItemType` LIKE ''%Cloak%' ORDER BY ItemName ASC";
  14. 1.) You should be using the .= operator, not =, to append to $catagories. You should also create the variable as an empty string prior to this to prevent an undefined variable notice. 2.) Nothing is displayed? What does that mean? Completely blank page? Did you check the source?
  15. A salted md5() renders radinbow tables useless in just the same way salting sha1() does. Sure, md5() has been shown to have vulnerabilities, but the existance of rainbow tables isn't one of them with a salt.
  16. Ill direct you do a topic a couple down from yours: http://www.phpfreaks.com/forums/index.php/topic,208554.0.html It's basically the same principle.
  17. Cycle through the results and add to the array each time you do: <?php $sql = "SELECT field FROM table"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $array = array(); while($row = mysql_fetch_assoc($result)){ $array[] = $row['field']; } print_r($array); ?>
  18. As i said earlier, you can convert new lines to break line tags with the nl2br() function. You should do this just before you echo the data.
  19. What do you mean by "the form doesn't work"? You should only be using one query if you're just trying to select different fields. We need a bit more information and, most likely, a bit more code.
  20. I'm not sure if I follow your question, but you're always going to need some sort of delimiter if you wish to store data in a text file. What you choose to use is up to you; though you must remember to ensure that it cannot occur in the input.
  21. Judging from your image names, you might want natsort().
  22. You want to convert them to break line tags when you output the data. As a general rule, you should preserve data how it was written and format it for presentation at the point that you present it. As for how to do it, use the nl2br() function.
  23. Recursive function? <?php $array = array(1,2,array(2.1,2.2,2.3,array(2.31,2.32,2.33)),3,4,array(4.1,4.2,4.2),5); function convertToUl($array){ echo "<ul>\n"; foreach($array as $v){ if(is_array($v)){ convertToUl($v); }else{ echo '<li>'.$v."</li>\n"; } } echo "</ul>\n"; } convertToUl($array); ?> Edit: Not quite right. I'll have another go. I hate writing recursive functions. Particularly late at night.
×
×
  • 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.