Jump to content

codefossa

Members
  • Posts

    583
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by codefossa

  1. Could you please format and use code tags?
  2. Driver.php needs to be a string in the load function. But what I was saying is that you ain't passing the value, so you may as well make it a button or link. What I posted doesn't refresh to load, but you have to use another page to get the data. JS can't interact with your database, it can only call on a PHP script to make it execute and it can show the results.
  3. $.load() uses a string. You don't seem to close your option tags. Lastly, you didn't tell us what the problem is, or what errors you may be getting if you even have error reporting on. Also, what's the point of the options when you're using $.load() without any GET parameters? You're probably better off with $.post() for this since you probably don't want people just linking to the actions. Here's an example that you may be able to go off of. Demo Page: http://xaotique.no-ip.org/tmp/36/ HTML <select id="driver"> <?php for ($i = 1; $i < 6; $i++) echo '<option value="' . $i . '">' . $i . '</option>' . "\n"; ?> </select> <div id="content2"></div> Javascript / jQuery $(document).ready(function() { $("#driver").change(function() { $.post('', { opt: $(this).val() }, function(data) { $("#content2").html(data); }); }); }); PHP <?php if ($_SERVER['REQUEST_METHOD'] == "POST") { echo "<pre>", print_r($_POST), "</pre>"; die(); } ?>
  4. $.post('page.php', $(this).serialize()); Remember if you're using a submit button to do it, you need to return false or else you'll follow it.
  5. If you leave it empty you post to yourself (the same page). So it's pretty much just refreshing the page because you don't have it set up to deal with the form data. If you press F5, you should get a warning that you're going to resend data if you'd like some proof of it posting.
  6. It won't be live because you're using a hardcoded timestamp in JS, so you need a page refresh to make it live. You should create the timestamp within JS if you want to display it multiple times on any page load.
  7. It does work, but you didn't include jQuery. The example he gave: http://xaotique.no-ip.org/tmp/35/ Add the jQuery include in the HEAD. <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> You should also wrap your JS in a load trigger function. In jQuery, you can just use $.ready(). $(document).ready(function() { $("body").addClass("has-js"); });
  8. Show what you've got so far? Also, show the HTML so we can see how it's all set up.
  9. Is your font monospaced? If not, you can only estimate what would be close. As Andy said, this should be done in PHP because it's pointless to send a bunch of data you don't need. Maybe try something like this. <?php function word_limit($string, $limit) { $arr = preg_split('/\s+/', $string); return implode(' ', array_splice($arr, 0, $limit)); } $str = "One two three four five. Six seven eight nine ten, eleven twelve. Thirteen!!! Fourteen (:"; // Output: One two three four five. Six seven eight nine ten, eleven twelve. echo word_limit($str, 12); ?>
  10. You would check both. If you wanted to look for someone named James Howard, you could do .. `firstname` = 'James' AND `surname` = 'Howard' To search from the keyword, you would change the = '' to LIKE '%{$keyword}%' like you're doing. You just have to compare both, you don't choose two fields at the same time for comparing.
  11. http://www.w3schools.com/sql/sql_and_or.asp
  12. Didn't see him respond. ^^
  13. You could create a function that will do it from an array for strings found/replaced. Then like using preg_replace with an array in PHP, you would put the regex for each of the first array, and then the replacement in the second.
  14. You use them for styling and easy access in Javascript. The names are for form items you need sent as GET or POST parameters. If you don't need it, then there's no reason to put it there.
  15. I would assume. He didn't really explain very much, so I just guessed.
  16. $str = "2-lined-noted-pads-565.php"; $id = preg_replace('/(.*?)-([0-9]*)\.php$/', '$2', $str); echo $id; // Prints: 565
  17. It depends on if it's always the same, if you set the id, if it increments, etc. It's up to you and how you do it.
  18. I don't know because I have no idea what you're actually doing. You currently just have campaignId as a hidden field, and only one in the form. So your result was the correct amount posted.
  19. I'm not sure of the reason for this though, as you could just as easily use $_POST['clientId'] anywhere like you would $data['clientId'], but glad ya got it. (:
  20. Did you post the form? Are your variable correct? $clientId and $campaignId have to be some string. If you meant for it to be a string and not a variable, it would be 'clientId' => $_POST['clientId'], and the same with the next.
  21. Small suggestion, but it would be easier for me if we had the option to set the time to 24H for seeing when things were posted.
  22. $_POST is an array. You access what's inside it by its keys. $array['key'] $data = array( $clientid => $_POST[$clientid], $campaingId => $_POST[$campaignId] );
  23. No. You're trying to set an array with keys, correct? $data = array( 'key' => "value", 'key2' => "next 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.