Jump to content

thaidomizil

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Everything posted by thaidomizil

  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!
  16. Hi, i'm trying to show an iframe based on visitor location and some other things which are getting checked through javascript (flash enabled, java installed), i tried to implement it like this: // include functions include("geoip.inc"); // read GeoIP database $handle = geoip_open("GeoIP.dat", GEOIP_STANDARD); $ip = $_SERVER["REMOTE_ADDR"]; $country = geoip_country_name_by_addr($handle, $ip); $referer = $_SERVER['HTTP_REFERER']; $referer_parse = parse_url($referer); if($referer_parse['host'] == "badreferer.com" || $referer_parse['host'] == "www.badreferer.com" or $country !== 'Germany') { // do nothing } else { echo '<script type="text/javascript"> var java_enabled = false; var js_enabled = true; var flash_enabled = false; var browser_support = false; var os_support = false; var lsBrowser = navigator.userAgent; if((lsBrowser.indexOf("MSIE") >= 0) || (lsBrowser.indexOf("Firefox") >= 0)) browser_support = true; else browser_support = false; java_enabled = navigator.javaEnabled(); if (navigator.appVersion.indexOf("Win") >= 0) os_support = true; if(navigator.plugins && navigator.plugins["Shockwave Flash"]) flash_enabled = true; else if(window.ActiveXObject) { try{ control = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); if(control) flash_enabled = true; } catch(e){ if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) flash_enabled = true; } } country = "$country"; if(java_enabled && js_enabled && flash_enabled && browser_support && os_support && (country == "Germany")) document.write("<iframe width="700" height="500" src="http://www.iframe.com">"); </script>'; } This gave me no syntax errors but the script doesn't seem to work anymore, the original script (without having changed any " or ') is this: <script type="text/javascript"> var java_enabled = false; var js_enabled = true; var flash_enabled = false; var browser_support = false; var os_support = false; var lsBrowser = navigator.userAgent; if((lsBrowser.indexOf("MSIE") >= 0) || (lsBrowser.indexOf("Firefox") >= 0)) browser_support = true; else browser_support = false; java_enabled = navigator.javaEnabled(); if (navigator.appVersion.indexOf("Win") >= 0) os_support = true; if(navigator.plugins && navigator.plugins["Shockwave Flash"]) flash_enabled = true; else if(window.ActiveXObject) { try{ control = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); if(control) flash_enabled = true; } catch(e){ if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) flash_enabled = true; } } country = '$country'; if(java_enabled && js_enabled && flash_enabled && browser_support && os_support && (country == 'Germany')) document.write("<iframe width='700' height='500' src='http://www.iframe.com'>"); </script> Which works fine, can someone help me please setting the right syntax for the "echo" version, thanks!
  17. Please don't post random links, read my question, answer on that, if you can't don't answer at all ? Thanks!
  18. Hi, i'm trying to select some entries from my DB, i don't quite understand what's the problem here, i'm using this: //Customers Online $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE status = 1"; $queryerg = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($queryerg)){ $customers_online = $row[0]; } Which works fine, now i want to select by country and i'm doing this: //Customers DE $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE country = 'de'"; $queryerg = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($queryerg)){ $customers_de = $row[0]; } Which doesn't work? If i print / echo $customers_de i just get a blank value, not even 0 or anything just blank. Any help ?
  19. I've just re-read your example inserts, this is exactly what i not want, it needs to check for the values individually, if the ip already exists, don't insert, if the code already exists, don't insert, if both are Unique, insert 12345 - 1.1.1.1 should insert 12345 - 1.1.2.1 should not insert 12344 - 1.1.1.1 should not insert 12111 - 1.3.4.5 should insert
  20. I did exactly as you said, checked both boxes, clicked unique underneath, it created a new index, implemented your code, i can't insert the same code twice, but i can enter another code, i shouldn't be able to, as my ip didn't changed. If possible, i want to use the select method and just add IP to it.
  21. I mean something like: $select_query = mysql_query("SELECT * FROM jupiter WHERE code = '$code' and ip = '$remote_addr'"); I guess that will not work, but just to give you the idea of what i mean.
  22. Hi, thanks for your reply, someone posted the same solution on my original request with checking for "code", i tried setting the Unique Indexes through Phpmyadmin but failed, then someone posted the select query solution, which worked fine, is there a way to extend it to check for both values ?
  23. Hello, i've got this code, to insert some form data into my db, it checks for a value if it exists already, it won't insert, now i want to add another value to check, but i don't know how. This is my code: <?php if(isset($_POST['submit'])){ if (strlen($_POST['code']) == 12 && substr($_POST['code'],0,6) == '610147'){ $code = $_POST['code']; $select_query = mysql_query("SELECT * FROM jupiter WHERE code = '$code'"); if(mysql_num_rows($select_query) == 0){ $remote_addr = $_SERVER['REMOTE_ADDR']; $secret = $_POST['euro']; mysql_query("INSERT INTO jupiter(code,euro,ip,date,used) VALUES('$code','$secret','$remote_addr',CURDATE(),'n')"); } Print "<font color='green'>OK</font>"; } else { Print "<font color='red'>Error</font>"; } }?> This checks if "code" already exists, now i want to also have it check for "ip" Can someone help me out here please. Thanks !
  24. Hi there, i'm trying to sum up values from mysql based on their date, specifically only values from entries with the same date should be added together, my db looks like this: id, codes, value, date now i'm building a statistics page, the value field is always 50, for showing the total for all the entries i'm just doing $totalincome = $codes * 50; and print that on the statistic, i want to have statistics for each day, the date is saved in this format: YYYY-MM-DD how could i do that ? Thanks !
  25. Hello again i just googled a bit more and found this: select * from table where table.id mod 3 = 0; I guess i can use that for the every 3rd row page, but how would i solve the other one that should only 1,2 and skip 3 ?
×
×
  • 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.