NoobLaPHP
Members-
Posts
20 -
Joined
-
Last visited
Everything posted by NoobLaPHP
-
I managed to sort it. Not sure if it is correct but it works var interval = setInterval(function() { // ajax call $.get ( "my_ajax.php", function(data) { $("#divA").html(data.A); // put results into their $("#divB").html(data.B); // respective divs }, "json" ) },1000); Cheers for your help.
-
Nice, this is doing exactly what i need. Now another question i have is, is there a way to get this to refresh using some sort of setInterval?
-
I am trying to reload multiple divs. for things like mail and notifications on the same page of a website. I want to call all the information from another page but am unsure where to go as i have only just started learning more about ajax. I want to set it to call for the information just using something basic like <span id=notifications></span> To which it will show up the text needed when on the website but i really don't know where else to start. Any help will be greatly appreciated
-
You sir, are awesome! after a few tweaks, i managed to fix it and get it working as it should. Thank you.
-
It's sending the id through as 32. 71. 10 Not sure what i've done or haven't done. All i did was fill in the blanks
-
I don't fully understand ajax, i'm still learning all this. I have done it using php. The value gets the like part and also the id for the post to like so it will be like like:387 if the php reads the like, it then reads the id where it updates the database $replyid = mysql_real_escape_string(addslashes(strip_tags($liked[1]))); mysql_query("UPDATE replies SET likes='...' WHERE id='$replyid'"); etc, any help is good. It helps learn
-
It requires both items to be filled. If either is empty it shows nothing if($liked[0] == "like"){ if(!$liked[1]){ //Do nothing }else{ //Select from database where id is $liked[1] } }
-
$liked = explode(":", $_POST[submit]); if($liked[0] == "like"){ //Select from database where id is $liked[1] } <input type="image" src="images/arrowup.gif" name="submit" value="like:<? echo $right->id; ?>"/> Ok, so i have made a forum and i have a like function running on the comments of a post. I needed to find a way when the image was clicked it updated the database. So i experimented and came up with the solution above having it explode the value of the button to read if it was press and get the id. It works perfectly but i just want to be convinced it is safe.
-
function updateTimers() { //Get the current timestamp now = new Date(); //Iterate through each of the timers for(i=0; i<timers.length; i++) { //Convert end time to timestamp & calc difference endTime = new Date(timers[i].split(' ').join('T')); millisecondsDiff = endTime - now; //Format the diff and display timeDisplay = formatTimeDiff(millisecondsDiff); document.getElementById('timer['+i+']').innerHTML = timeDisplay; } } I'm using the above function to set timers for a page on my website. It should be showing 23 minutes but is showing 83 minutes. This has only come about since the clocks in the UK went forward. Ant help?
-
Figured it out. I used $where = "where".$select; if($fetch->$where){ mysql_query("UPDATE `table` SET `$where`='input' ");
-
I have a select option and want to include it in my query. $select = mysql_real_escape_string($_POST[select]); if($fetch->where$select){ So if the select value was at 2 it would read if($fetch->where2){ How would i do it? Would if($fetch->where.$select){ work putting in a . ? also in the mysql mysql_query("UPDATE `table` SET `where$select`='input' ");
-
I have found this that seems to work well. function domain_exists( $email, $record = 'MX' ) { list( $user, $domain ) = explode( '@', $email ); return checkdnsrr( $domain, $record ); } if(domain_exists('user@davidwalsh.name')) { echo('This MX records exists; I will accept this email as valid.'); } else { echo('No MX record exists; Invalid email.'); } Source: http://davidwalsh.name/php-email-validator
-
Ok, i am having a load of people register to a subscription service on my website using invalid emails. I would like to add a function in that can read an email. If the source is right it will continue to process the form. If it's not then it shows an error message. Would i use something like an explode function to seperate using the @ in an email and read the end part(live.co.uk) and then have an array set up to see if the end is in the email or what? Examples would be a great help if you have any other ideas. Thanks
-
I'm completely lost in this. For some reason i keep losing 3 seconds but only in the auto countdown. The timer itself remembers the 15secs yet when it starts counting down it skips to 12
-
Figured it out. Sorry to seem like such a noob. I added if(minutes < 10) { minutes = '0'+ minutes; } if(seconds < 10) { seconds = '0'+ seconds; }
-
Thank you for your help. One last question about the snippet you provided. How would i go about having it show as just 00:15. At the minute it shows as 0:0:15. Is it possible?
-
No i am not using datetimes. I'm using $tim = time() + 15; which then gets turned into a load of numbers in the database. Then to get the outcome i need as $left = $timer - time(); echo secondsCount($left); then i use the secondsCount() function to give me the timer of 15secs.
-
timers[0] = "<? echo $timer1; ?>"; timers[1] = "<? echo $timer2; ?>"; timers[2] = "<? echo $timer3; ?>"; <div id='timer[0]'>15secs</div><br> <div id='timer[1]'>45secs</div><br> <div id='timer[2]'>02mins 15secs</div><br> How would i go about using the current output i have with the secondsCount(); function?
-
It's running off a function. The function i am using is this $left = $timer - time(); echo secondsCount($left); $tim = time() + 15; mysql_query("UPDATE table SET time='$tim' WHERE username='$username'"); function secondsCount($int) { if($int < 60) { $minutes = $int / 60; $seconds = $int % 60; $minutes = (int)$minutes; $seconds = (int)$seconds; if($seconds < 10) { $seconds = "0$seconds"; } $string = $seconds . "secs"; } elseif($int < 3600) { $minutes = $int / 60; $seconds = $int % 60; $minutes = (int)$minutes; $seconds = (int)$seconds; if($minutes < 10) { $minutes = "0$minutes"; } if($seconds < 10) { $seconds = "0$seconds"; } $string = $minutes . "mins " . $seconds . "secs"; } elseif($int > 86400) { $days = $int / 86400 % 7; $hours = $int / 3600 % 24; $minutes = $int % 3600 / 60; $seconds = $int % 3600 % 60; $days = (int)$days; $hours = (int)$hours; $minutes = (int)$minutes; $seconds = (int)$seconds; // if($hours < 10) { $hours = "0" . $hours . ""; } // if($minutes < 10) { $minutes = "0" . $minutes . ""; } if($seconds < 10) { $seconds = "0" . $seconds . ""; } $string = $days . "days " . $hours . "hrs "; } else { $hours = $int / 3600; $minutes = $int % 3600 / 60; $seconds = $int % 3600 % 60; $hours = (int)$hours; $minutes = (int)$minutes; $seconds = (int)$seconds; // if($hours < 10) { $hours = "0" . $hours . ""; } // if($minutes < 10) { $minutes = "0" . $minutes . ""; } if($seconds < 10) { $seconds = "0" . $seconds . ""; } $string = $hours . "hrs " . $minutes . "mins " . $seconds . "secs"; } return $string; } i need the echo to automatically refresh for 6 different timers all shown on the same page.
-
I have 6 timers all running of a php page ranging from 15seconds to 6minutes. However you need to refresh the page to watch it countdown. I would like to set these up to do it so they all run down without having to keep leaving the page bur it showing up a message when the timer runs out.