Jump to content

thaidomizil

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

thaidomizil's Achievements

Member

Member (2/5)

0

Reputation

  1. This works: echo chunk_split($text, 4, " "); Could someone tell me how do i add a line break after every number (16th digit) ?
  2. Hello everyone, I'm exporting some mysql data to a text file. The data can be selected by checkboxes from a table. I want to format the text that will be in text file. How do I do that? This is my code: <?php if ($_POST['exporttxt']) { for($i=0;$i<count($_POST['checkbox']);$i++){ $export_id = $checkbox[$i]; $text = mysql_query("SELECT code FROM tickets WHERE id='$export_id'"); $text = mysql_fetch_assoc($text); $text = $text["code"]; $filename = "export"; $filedate = date("Y-m-d"); $fileext = ".txt"; $fileall = $filename.$filedate.$fileext; ob_end_clean(); header("Content-Type: application/octet-stream"); header("Content-disposition: attachment;filename=\"$fileall\""); header("Content-Type: application/force-download"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); header("Content-Length: ".strlen($output).";\n"); echo($text); } } exit(); ?> The data that will be exported are numbers containing of 16 digits. After every number I want to have a line-break. Also if possible I would like to have a space after 4 digits for every number, example: Number non-formatted: 1234567891234567 Number formatted: 1234 5678 9123 4567 How can I do that?
  3. Then something else is wrong ? If i select some rows and press my submit button, it submits the form, and shows me the output of what i selected i.e some codes which i actually want to write to the .txt file, i definitely included the headers.
  4. The output on the screen is correct, but it still doesn't offer me any download, also tried with the code you suggested, same result.
  5. I've got it to show the proper output atleast with all select boxes working, but it won't download the .txt file, i've tried with this headers and code: <?php if ($_POST['exporttxt']) { for($i=0;$i<count($_POST['checkbox']);$i++){ $export_id = $checkbox[$i]; $text = mysql_query("SELECT code FROM psc WHERE id='$export_id'"); $text = mysql_fetch_assoc($text); $text = $text["code"]; ob_end_flush(); header("Content-type: text/plain"); header("Content-disposition: attachment;filename=\"filename.txt\""); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); header("Content-Length: ".strlen($output).";\n"); echo($text); } } ?> Like i said, the output itself is correct, but it won't offer me to download the .txt file.
  6. Hello kicken, thanks for your reply, i noticed the second point you mentioned but couldn't really figure out why that was happening / or how to fix it? to third: it would be great if you could give me an example. Thanks!
  7. Definition of doesn't work: it doesn't do anything. Is that accurate enough ?
  8. Hi, i have a table which shows some mysql data, every entry has a checkbox to select individual entries, now i want to be able to export those selected entries into a xml or txt file, i tried this: <?php if($_POST['exporttxt']){ for($i=0;$i<count($_POST['checkbox']);$i++){ $export_id = $checkbox[$i]; $sql = "SELECT * FROM table WHERE id='$export_id'"; $result = mysql_query($sql);} $output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root>\n"; if($result->num_rows > 0) { while($myrow = $result->fetch_assoc()) { $output .= "\t<row>\n"; foreach($myrow as $_name => $_value) { $output .= "\t\t<$_name>$_value</$_name>\n"; } $output .= "\t</row>\n"; } } $output .= "</root>"; } header('content-type: text/xml'); header('content-disposition: attachment; filename=data_export.xml'); echo $output; exit; ?> but that doesn't seem to work. Any hints ?
  9. Hello all, i have a table that displays data from mysql, now i want to update multiple rows from that table with checkboxes, the value will basically just switch from 'new' to 'done' so far i have this: <tbody> <tr class="first"> </tr> <?php $ticketde=0; while ($ticketde < $numpscde) { $f1pscde=mysql_result($ticketresultde,$ticketde,"id"); $f2pscde=mysql_result($ticketresultde,$ticketde,"ticket"); $f4pscde=mysql_result($ticketresultde,$ticketde,"date"); $f5pscde=mysql_result($ticketresultde,$ticketde,"ip"); $f6pscde=mysql_result($ticketresultde,$ticketde,"done"); $setdone = ($f6pscde["done"] == 'n') ? "<a href=\"donepsc.php?id=".$f1pscde."\"><img src=\"ico_new.gif\" alt=\"new\" /></a>" : $f6pscde["done"]; if(isset($_POST['setdone'])){$checkbox = $_POST['checkbox']; $id = "('" . implode( "','", $checkbox ) . "');" ; $sql = "UPDATE ticket SET done='done' WHERE id='$f1pscde'"; $result = mysql_query($sql) or die(mysql_error()); } ?> <tr class="first"> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f1pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f2pscde; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f5pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $setdone; ?></font></td> <td class="tc"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $f1pscde['id']; ?>"></td> </tr> <?php $ticketde++; } ?> </tbody> </table> <center><input type="submit" name="setdone" id="setdone" value="Set selected to done" class="button"/> - <input type="submit" name="exporttxt" id="exporttxt" value="Export selected to .txt" class="button"/> </center> </fieldset> </form> I found that checkbox code sample on some other site and tried to implement it, i don't really know where to go from here, as it's a total mess to me now, any help would be greatly appreciated.
  10. Now i've tried this: $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE country = 'de' AND DATE('registertime') = DATE(NOW())"; $queryerg = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($queryerg)){ $registrationstoday = $row[0]; } But for some reason it's showing me 0 ? What am i doing wrong ? Edit: removed the ' ' .. it works now! Now how can i subtract one day from this DATE(NOW())"; ? So it's showing me the result for yesterday
  11. Hello, i'm trying to get the number of users that registered today and the number of users that registered yersterday (seperate), i've got this field in mysql: 'registertime' which stores data in this format 2011-11-14 14:53:49 also i have the field 'time' in the same format that updates everytime the user logs in. Now previously i wanted to find out users online in last 24 hours, the code i used for that is this: $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE country = 'de' AND time BETWEEN DATE_SUB( NOW(), INTERVAL 24 HOUR ) and NOW() "; $queryerg = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($queryerg)){ $customers_on_de_24 = $row[0]; } How could i edit that to select the count just by date and ignore the time (hours minutes seconds) ?
  12. Thank you Pikachu, i expected to have some logical error in there, your solution works great anyhow!
  13. Hi, i'm trying to create some detailed statistics about customer activity, i have entries in my mysql db when the customer has been active for the last time and want to create some statistics about that, basically a "online last 24 hours" but from specific countries. Now i've tried this: $time = date('Y-m-d H:i:s'); $time24 = date("Y-m-d H:i:s", time()-((60*60)*24)); $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE country = 'de' AND time BETWEEN '$time' AND '$time24' "; to get the current date and select all customers that have been available from the current date minus 24 hours, what's my mistake here, as this doesn't seem to work! Thanks
  14. Hello, i'm using this piece of code to refresh my div every X seconds: <script> $(document).ready(function() { $("#container").load("stats.php"); var refreshId = setInterval(function() { $("#container").load('stats.php'); }, 9000); $.ajaxSetup({ cache: false }); }); </script> This works great, only thing i want to add is a slider like this one: http://jqueryui.com/demos/slider/#steps I want it to be able to set the interval on the refresh timer which is by default 9000 (ms?) Is it possible to let the slider modify the value ? if so, how can i do that ? thanks!
  15. Just googled a bit more and found 'heredoc' which works wonders :-) Topic solved!
×
×
  • 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.