Jump to content

xwishmasterx

Members
  • Posts

    186
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

xwishmasterx's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Sorry for the not-so-clear head line. I need some help with an existing script that uses array to display af graph. The existing script is as below: $p->data = array( array(array("2010-10-01",48.25),array("2010-01-01",238.75),array("2011-01-01",95.50)), array(array("2010-10-01",14.25),array("2010-10-4",438.75),array("2010-10-6",125.50)) ); The two lines in bold are each af line consisting of 3 points. The question is how can I get the data form my database to match such a line? EG: Column: DATE, A,B should be able to output array(array("DATE",A),array("DATE",A),array("DATE",A)), array(array("DATE",B),array("DATE",B),array("DATE",B)), (assuming I have 3 values of each ofcourse). Any help will be appreciated.
  2. Hi I have a small script, on a single file that needs to be optimized. file is about 300 lines (16Kb), and basiccaly looks like the "PHP-monster" threw up on it. Script is working ok, but surely could be much better. PM if interested and I can send you a copy of file. If possible leave price/hourly rate.
  3. Hello. I'm having some issues with a select statement containing ABS(). Here's the select query: "SELECT gadenavn, husnr, ABS(husnr - $husnr) AS husnr_range, postnr,db, shaping, dsl_node, ctr_node, db_ctr_luftlinje, bynavn FROM `TABLE 1`, Post_numre WHERE `postnr`=`postnummer` AND `gadenavn`=`$vejnavn` AND `postnr`=`$postnr` AND `husnr`>0 ORDER BY husnr_range ASC LIMIT 5" Now lets asume my variable "$husnr" is a value of 15. In my table I have the values for coulmn "husnr": 13,12,11,10,9 What really bugs me is the outcome doing af simple "while loop" is returning the values 12,11,10,9. What happened to 13?! printing the "husnr_range" values shows "3,4,5,6". What puzzles is the row missing, as I only get 4 results, with a "LIMIT 5". Can anyone explain why the last resulst isn't included?
  4. I see it works as intended - however a crucial thing is missing: "newOption.id" variables are gone
  5. Complete java-noob need a little help. I have this small script that generates simple dropdown menu depending on previous selection: var populateSubList = function() { var firstList = document.getElementById("list_One"); var secondList = document.getElementById("list_Two"); if (firstList && secondList) { var value = firstList.options[firstList.selectedIndex].value; secondList.options.length = 0; /* Do some work here to create elements to add to the second list */ if (value == "hw") { var newOption = document.createElement("OPTION"); newOption.text = "hw firmware"; newOption.value = "fw_ukendt"; newOption.id = "fw_ukendt"; secondList.add(newOption); } else if (value == "2601") { var newOption = document.createElement("OPTION"); newOption.text = "2601 firmware1"; newOption.value = "fw1"; newOption.id = "fw1"; secondList.add(newOption); } else { } } }; Now the above code works perfect, but I just can't seem to add another "item". My logic brought me to simply duplicate an option like so: var populateSubList = function() { var firstList = document.getElementById("list_One"); var secondList = document.getElementById("list_Two"); if (firstList && secondList) { var value = firstList.options[firstList.selectedIndex].value; secondList.options.length = 0; /* Do some work here to create elements to add to the second list */ if (value == "hw") { var newOption = document.createElement("OPTION"); newOption.text = "hw firmware"; newOption.value = "fw_ukendt"; newOption.id = "fw_ukendt"; secondList.add(newOption); } else if (value == "2601") { var newOption = document.createElement("OPTION"); newOption.text = "2601 firmware1"; newOption.value = "fw1"; newOption.id = "fw1"; secondList.add(newOption); var newOption = document.createElement("OPTION"); newOption.text = "2601 firmware2"; newOption.value = "fw2"; newOption.id = "fw2"; secondList.add(newOption); } else { } } }; This does show a new option in the menu, but can't be chosen... Can someone enlighten me on how to make it work?
  6. Tried that also. The really wierd thing is I'm using the style on other forms/inputs without issues and only have one stylesheet. I did a work around for now (adding value=" " - then remving the whitespace on sending) will mark as solved anyways. thanks for the ideas
  7. Already tried that..thanks. It seems it's the background property that isn't working as I can style height, width etc.. What puzzles me is that adding something to the name attribute kills the background style. Seems adding any value to the input and css works fine again.
  8. Hello I have a very wierd problem. Below code is a simple login form: <form action="verify.php" method="post"> User Name:<br> <input type="text" class="login" name="" ><br><br> Password:<br> <input type="password" class="login" name="password"><br><br> <div align="center"><input type="submit" name="submit" value="Login"></div> </form> The above code works fine, but if I add any value to the name attribute in the first input field, the style doesn't work. (except if I enter "password") Seems the css for background-image isn't added when entering anyname. Anyone have an idea why this happens?
  9. Hello doing a simple "preg_replace", but ending up with an extra " / ".. $str = preg_replace("/'/", "%27", $str); Seems the "%" is adding an extra "/".. Anyone can help me explain why, and what the solution is?
  10. Hello I am having issues trying to sort some some results. example results from table: 30/1 8/2 12/1 12/2 How can I sort these to make value before "/" go first and if first value are the same the the value after "/" be first: 30/1 12/2 12/1 8/2 All ideas appreciated
  11. What I do not understand is basically the script just ouputs html code, why can't it simply output php?..but if it generally can't be done I'll look in some other direction..thanks for the reply.
  12. I have part of code as shown below: newdiv.innerHTML = "<a href=\"javascript:;\" onclick=\"removeElement(\'"+divIdName+"\')\"><div style='position:relative;top:5px;left:980px'><img src='luk.png' style='position:absolute' height='50' width='50'></div></a><div align='center'>THIS IS SHOWNG FINE</div> Basically clicking a link will show "THIS IS SHOWING FINE". I want it include som php instead like <?php include "myfile.php"; ?> How can this be achieved?
  13. thanks alot for the links..looks pretty difficult though I'll give it a try, but there's a decent chance I'm gonna end up at the freelancer forum Thanks for your replies
  14. Is there a way to overcome this issue? What puzzels me if you're right, that if I run the code without the form it works perfectly (bar turning red when a ping times out). However if you're saying the ajax doesn't remember the values then why am I getting a positive result (ping is replied) if the values aren't there?
  15. You're absolutely right. Here's the entire code that won't work with the form inputs, but will work if variables are added into the code. As mentioned the form does work. <?php /* * * Use the examples below to add your own servers * */ $title = "EZ Pinger"; // website's title $kunde = $_POST["kunde"]; $ip = $_POST["ip"]; $port = $_POST["port"]; $note = $_POST["note"]; $servers = array( 'Example Down Host' => array( 'ip' => $ip, 'port' => $port, 'note' => $note ) ); if (isset($_GET['host'])) { $host = $_GET['host']; if (isset($servers[$host])) { header('Content-Type: application/json'); $return = array( 'status' => test($servers[$host]) ); echo json_encode($return); exit; } else { header("HTTP/1.1 404 Not Found"); } } $names = array(); foreach ($servers as $name => $info) { $names[$name] = md5($name); } ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title><?php echo $title; ?></title> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootswatch/2.3.2/cosmo/bootstrap.min.css"> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css"> <style type="text/css"> /* Custom Styles */ </style> </head> <body> <div class="container"> <h1><?php echo $title; ?></h1> <form method="post" action="<?php echo $PHP_SELF;?>"> Kundenummer:<input type="text" size="20" maxlength="20" name="kunde"><br /> IP:<input type="text" size="20" maxlength="20" name="ip"><br /> Port:<input type="text" size="20" maxlength="20" name="port"><br /> Note:<input type="text" size="20" maxlength="20" name="note"><br /> <input type="submit" value="submit" name="submit"> </form> <table class="table"> <thead> <tr> <th></th> <th>Kunde</th> <th>IP</th> <th>Port</th> <th>Note</th> </tr> </thead> <tbody> <?php foreach ($servers as $name => $server): ?> <tr id="<?php echo md5($name); ?>"> <td><i class="icon-spinner icon-spin icon-large"></i></td> <td class="name"><?php echo $kunde; ?></td> <td><?php echo $ip; ?></td> <td><?php echo $port; ?></td> <td><?php echo $note; ?></td> </tr> <?php endforeach; ?> </tbody> </table> </div> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script type="text/javascript"> function test(host, hash) { // Fork it var request; // fire off the request to /form.php request = $.ajax({ url: "<?php echo basename(__FILE__); ?>", type: "get", data: { host: host }, beforeSend: function () { $('#' + hash).children().children().css({'visibility': 'visible'}); } }); // callback handler that will be called on success request.done(function (response, textStatus, jqXHR) { var status = response.status; var statusClass; if (status) { statusClass = 'success'; } else { statusClass = 'error'; } $('#' + hash).removeClass('success error').addClass(statusClass); }); // callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown) { // log the error to the console console.error( "The following error occured: " + textStatus, errorThrown ); }); request.always(function () { $('#' + hash).children().children().css({'visibility': 'hidden'}); }) } $(document).ready(function () { var servers = <?php echo json_encode($names); ?>; var server, hash; for (var key in servers) { server = key; hash = servers[key]; test(server, hash); (function loop(server, hash) { setTimeout(function () { test(server, hash); loop(server, hash); }, 6000); })(server, hash); } }); </script> </body> </html> <?php /* Misc at the bottom */ function test($server) { $socket = @fsockopen($server['ip'], $server['port'], $errorNo, $errorStr, 3); if ($errorNo == 0) { return true; } else { return false; } } function in_array_r($needle, $haystack, $strict = false) { foreach ($haystack as $item) { if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) { return true; } } return false; } ?>
×
×
  • 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.