Jump to content

SergeiSS

Members
  • Posts

    239
  • Joined

  • Last visited

Everything posted by SergeiSS

  1. Request to moderators: change, please, my previous answer in this topic. My answer looks like some kind of internal quoted text
  2. Change your code $sql = "select * from players ORDER BY Rand() LIMIT 32"; $res = mysql_query($sql) or die (mysql_error()); $players=array(); while ($row = mysql_fetch_array($res)) { $players[]=$row['player']; // some more code } // do whatever you wish with array $players
  3. I think you misunderstand something. What are you comparing?... Numbers, strings? In your case all variables are compared as numbers. $night_start = '180001'; $night_end = '055959'; if (($time >= $night_start) && ($time <= $night_end)) // your condition is changed to if( $time >= 180001 and $time <= 55959 ) What do you think - is it possible? I'm not sure You need special functions like strtotime() or functions from DateTime object. Look for help here http://www.php.net/manual/en/
  4. 2 days before exact date, including this date where `date` between ( DATE('d-m-y') - INTERVAL 2 day ) and DATE('d-m-y') 2 days after exact date, including this date where `date` between DATE('d-m-y') and ( DATE('d-m-y') + INTERVAL 2 day ) If you change DATE('d-m-y') to CURRENT_DATE you'll get dates relatively to current date.
  5. In the second query you use this condition "t2.date <= CURRENT_DATE AND t2.date <= (CURRENT_DATE - INTERVAL 2 DAY )". What does it mean? It means that you like to see all dates that a less than 2 days before today. Check all conditions and you'll understand it. But it your start question you wrote ANOTHER condition: dates might be between 2 days before today and current date. Do you see the difference? It means that your dates are older than 2 days before... BTW... Try this query and you'll see all dates in your table select distinct `date` from `table2` order by `date` asc
  6. First... You didn't answer - what type of SQL server do you use. What is a type of you 'date' field? And one more question - why do you use reserved word for field name? It's possible, but is not recommended. Then. Try this query select * from table2 where date between ( DATE('d-m-y') - INTERVAL 2 day ) and DATE('d-m-y') if you use MySQL try this select * from `table2` where `date` between ( DATE('d-m-y') - INTERVAL 2 day ) and DATE('d-m-y')
  7. What do you mean "it dosen't seems to work"? Do you have any error or you don't have an expected result? And - do you use MySQL or other SQL?
  8. Try to show it: // version 1 echo '<pre>'.$your_text.'</pre>'; // version 2 echo '<textarea>'.$your_text.'</textarea>'; BTW, do you enter your text via a form, inside textarea tag?
  9. You may try the next algorithm... It will work for any DBs, even when they a placed at different places. 1. Copy your data into file. "SELECT ... INTO OUTFILE" will help you. 2. Copy files to another server, if needed. 3. Load data from file to another database, use "LOAD DATA INFILE". At this step you may load info to a columns with any name. Check syntax for these commands in the MySQL help.
  10. I like to answer such questions - when TS does something and needs to clarify just a small part OK. Change this <?php // not sure what to put here... ?> to <?php if( any_condition ) echo 'selected="selected"'; ?> any_condition depends on information from DB (if you like to set the default value for radio - it seems it's your case) or from the $_POST or $_GET array (if this script depends on previous one). And of course just one condition must be true, for one radio from the set.
  11. This http://ru.php.net/manual/en/book.datetime.php may help you.
  12. "Please make the code" costs some $$$... An advice costs nothing. Read this, it might helps you: http://ru2.php.net/manual/en/book.dir.php
  13. Read here what I mean: http://en.wikipedia.org/wiki/Database_trigger It's easier to do with help of flags.
  14. As I see you are inserting THE SAME DATA into 2 different tables. I think it's better to change your algorithm. You'd better insert data into 1 table and just have a flag showing if this mail is sent or not. It keeps DB space, it makes easier your script. But if you still like to use 2 tables, try triggers, as I said before. You'll find it more convenient.
  15. I'm not sure that I understand you exactly. But you may use 2 possibilities: (1) trigger allows you to do whatever you wish before/after performing any action in the table (for example, you may add or change any info in other table) and (2) if you use autoincremented field you may get it's new value just after insertion.
  16. In the help for date() function http://ru.php.net/manual/en/function.date.php it's written "To format dates in other languages, you should use the setlocale() and strftime() functions instead of date(). "
  17. BTW... Why do you insert the same info into 2 different tables? It's not normal.
  18. What are you going to do I wonder??? $check1 is an integer value because you just assign an integer to it. But you check it as the element from array $check1.... Do you think it's a good idea?
  19. Change ',)' in the second query to ')'. At the end of query.
  20. The best solution is to use special functions: http://ru.php.net/manual/en/function.end.php Here is just an example how to use it $a=array( 'a'=> 45, 'ljlsdjf', 'adjfosjf', 'cd'=>33); echo 'Direct order<br>'; foreach( $a as $k=>$e ) { echo "a[$k]=$e<br>"; } echo 'Reverse order<br>'; for( $e=end($a), $k=key( $a ); current( $a ); $e=prev( $a ), $k=key($a) ) { echo "a[$k]=$e<br>"; } It works with any kind of keys. PS. I changed a little the initial code, I've added a printout of direct order.
  21. It's impossible! It might work. Could you make a printscreen and show it? Include URL in this printscreen.
  22. You forget ';' at the end of previous line (I bet it's number is 73)
  23. You forget ')' at the end. And.... Why do you add 2 empty strings - one in the beginning and other at the end? You don't need it. Just write the variable without these empty strings.
×
×
  • 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.