Jump to content

xwishmasterx

Members
  • Posts

    186
  • Joined

  • Last visited

Everything posted by xwishmasterx

  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; } ?>
  16. Hello I hope someone here can help me out as this is starting to drive me crazy Below is a piece of code that I simply cannot figure out: $ip = $_POST["ip"]; $port = $_POST["port"]; $note = $_POST["note"]; $servers = array( 'Google Web Search' => array( 'ip' => $ip, 'port' => 80, The problem is the $ip variable. With the above setup the code won't work, although $ip value is correct. Adding the value directly in the script, instead of $_POST["ip"], it works perfectly. Anyone can answer me why, and maye point me in the right direction?
  17. Hello I'm currently working an a small project and need some help with some php/mysql coding. Probably need help a few times, and fast response too more help is important Currently I need som help with some JOIN tables (i believe that is what is required) Basically I have to tables and need to get specific output if some value is present in both tabels when doing a while loop. PM me ASAP if you can do this (and fast), and ofcourse your price. Casper
  18. You may want to look at this thread: http://stackoverflow.com/questions/13362874/retrieve-curl-data-with-client-headers-ip
  19. You're somhow not getting the right url.. taking from your own example "http://cs12492.vk.me/u15318088/videos/aa6b0afa06.720.mp4" the bold part is not correct...
  20. Your script works fine. Problem is those links are random generated (every 24 hours or so) to prevent people snatching them and use on their websites.
  21. That works just perfect! Thank you so much for taking time to help a novice!
  22. Sorry Psycho. I'm not getting these results from my own database. I'm wondering how I can "add" this part of the code (the results) $cast[$i]["name"] to the last part of code: $stringData = $cast[$i]["name"] ; fwrite($fh, $stringData); basically what I want, but obviously not working
  23. Thanks for the fast reply Psycho:) I think I was a little fast on the opening question, so please allowe me explain what I actually are trying to achieve here. Further down my little script I need to write this comma separated list to a simple txt file (I'm no wizard at this but so far this works well): $stringData = MY-COMMA-SEPERATED-LIST-SHUOLD-BE-HERE; fwrite($fh, $stringData); My main problem is I have no clue how to transform my list to something that works here :/
  24. I have the following code that obviously displays a table with some name: $cast = $movie->cast(); if (!empty($cast)) { ++$rows; echo '<TR><TD valign=top><B>Cast:</B></TD><TD>'; echo "<table align='left' border='1' style='border-collapse:collapse;background-color:#ddd;'><tr><th style='background-color:#07f;'>Actor</th><th style='background-color:#07f;'>Role</th></tr>"; for ($i = 0; $i < count($cast); $i++) { echo '<tr><td width=200>'; echo "<a href='person.php?engine=$engine&mid=".$cast[$i]["imdb"]."'>"; echo $cast[$i]["name"].'</a></td><td>'; echo $cast[$i]["role"]."</td></tr>"; } echo "</table></td></tr>\n"; } flush(); How can I display this as a comma seperated list? I only need the "names" ($cast[$i]["name"]) and nothing else as one sinle list with commas.
  25. Hello I am having difficulties getting the right result (basically I get the value "0") when trying to get the right value. $result=mysql_query("SELECT ((Kind*$a_kind)+(Nice*$a_nice)+(Brave*$a_brave)+(Caring*$a_caring)) as total, Chars FROM char_game_chars GROUP BY Chars ORDER BY total ASC LIMIT 1") From above code, the $a_kind,*$a_nice,*$a_brave and $a_caring depends on users answers, ans should get the "Chars" value that corresponds to the highest sum. How would I create the right expression to calculate the right value?
×
×
  • 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.