Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. mysql_query mysql_fetch_assoc mysql_fetch_row or, better, use the mysqli_ versions as mysql_ functions are deprecated
  2. GROUP BY school_barcode, type_content
  3. With PHP version < 5.4, the following willl work only if short_tags are enabled. <input type="text" name="name" value="<?=$name?>" /> if short_tags as disabled in the php.ini file you need to use <input type="text" name="name" value="<?php echo $name?>" /> Version >= 5.4 - this will work regardless of short_tag setting <input type="text" name="name" value="<?=$name?>" /> There should be no need for you to use eval() at all.
  4. In a previous post you gave your column names as so in your last example above you need to reference $row['std_cell'] and not $row['stdcell']. The $row array indices will be the same as the column names. Similarly, in your second code, you need $class['class_id'] and $class['class_name']
  5. try this method $adate = new DateTime('2013-10-20'); $bdate = new DateTime('2013-11-01'); $now = new DateTime(); $period = new DatePeriod($adate, new DateInterval('P1D'), $bdate); printf("%-15s\t%s\n", 'Date', 'Days elapsed'); foreach ($period as $dt) { printf("%-15s\t%6d\n", $dt->format('d M Y'), $dt->diff($now)->days); } /* RESULTS *************************************** Date Days elapsed 20 Oct 2013 26 21 Oct 2013 25 22 Oct 2013 24 23 Oct 2013 23 24 Oct 2013 22 25 Oct 2013 21 26 Oct 2013 20 27 Oct 2013 19 28 Oct 2013 18 29 Oct 2013 17 30 Oct 2013 16 31 Oct 2013 15 *****************************************************/
  6. Barand

    PHP script

    Then you have four options at least: Use a MySQL TIMESTAMP type column which will automatically set to current date on INSERT and optionally on UPDATE Use a DATE type column and place CURDATE() into the column on INSERT USE a DATETIME column and place NOW() into the column on INSERT Use PHP to get current date and place that in the date column
  7. +--------------+ +-------------------+ | class | | student | +--------------+ +-------------------+ | class_id (PK)|--+ | serial number (PK)| | class_name | | | std_name | | date_created | | | std_father_name | +--------------+ | | std_roll_num | +---<| std_class (FK)| | std_cell | | std_address | | std_dob | | std_fee | +-------------------+ The primary keys are the unique identifiers of each record. Assuming std_class contains the id of the student's class then that would be a foreign key. To query the table using a JOIN you would have a query like this SELECT c.class_name, s.std_name, s.std_father_name FROM student as s INNER JOIN class as c ON s.std_class = c.class_id ORDER BY c.class_name Note that you need InnoDB tables to define foreign key constraints. You do not have to formally define a foreign key to use a field in a join.
  8. Barand

    PHP script

    there is an example here http://forums.phpfreaks.com/topic/282860-selectingsearching-rows-of-a-table-based-on-the-value-of-a-field-in-the-table/?do=findComment&comment=1453412
  9. Check to see what mysql_error() contains after mysql_query(). Also echo $sql to see the query that is being executed
  10. Are the ids numeric in all cases?
  11. You seem to be over-complicating $in = 'test1.txt'; $out = 'test2.txt'; /******** * obfuscate */ $txt = file_get_contents($in); $str = ''; for ($i=0, $k=strlen($txt); $i<$k; $i++) { $str .= ~$txt[$i]; } file_put_contents($out, $str); /******* * output obfuscated text */ echo '<pre><hr>'; readfile($out); /******* * output deobfuscated text */ echo '<hr>'; $txt = file_get_contents($out); for ($i=0, $k=strlen($txt); $i<$k; $i++) { echo ~$txt[$i]; } echo '</pre>';
  12. number_format in the PHP or use ROUND() in the query SELECT ROUND(SUM(....), 2) as total
  13. Don't leave a space between the SUM and the ( ie SUM( and not SUM ( Another solution would be SELECT SUM(total) FROM ( SELECT SUM(balance) as total FROM account UNION SELECT SUM(-balance) as total FROM credit_card UNION SELECT SUM(-amount) as total FROM bills WHERE date > 12 ) as tots
  14. It's certainly the easiest way to get the total of the values in an array
  15. The first thing to say is don't run queries inside loops - extremely inefficient. Run a single query with a JOIN. The second is don't use SELECT *. Specify the individual column that you want to retrieve. The query time is proportional to the amount of data retrieved so only get what you need. It seems you are only really interested in data from table2 (I have to use * as I don't know your columns) $sql = "SELECT t2.* FROM table1 t1 INNER JOIN table2 t2 ON t1.id = t2.tab_id WHERE t1.type = 'med' AND t1.submission_type = 'submission'"; $query = mysql_query($sql); while ($row = mysql_fetch_assoc($query)) { $valueArr[] = $row; }
  16. Set the values of the radio buttons to 1 - 5. Then $_POST['answer'] will contain the number of the button selected
  17. Are you sure the path "files" is correct?
  18. No, it isn't. It is supposed to use readdir() to get the filenames which you then have to open then read. As I said
  19. The point is you have not used fopen on the file before using feof() or fgets()
  20. What have you got so far?
  21. try if it recognizes fopen before trying to read from a file
  22. see FAQ http://forums.phpfreaks.com/index.php?act=findpost&pid=1428660
  23. What do the posted day and time look like (formats)?
  24. Told you that earlier in reply #2!
  25. Add some debugging code after the update query. if(!$result) { echo 'Redeemer code is not valid, please try again.'; echo '<br>' . $sql . '<br>' . mysql_error(); }
×
×
  • 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.