Results 1 to 6 of 6

Thread: Php & mysql

  1. #1

    Default Php & mysql


    pwde pa help guys? unsay pamaagi nga ma display nmu ang data sa html within that day for example karun adlawa nya mu refresh napud ang data within the next day.. any sample code for reference, need lang jud kaau

  2. #2
    naa nkay nahimo o magpahimo ka?

  3. #3
    Quote Originally Posted by rudysandwich View Post
    pwde pa help guys? unsay pamaagi nga ma display nmu ang data sa html within that day for example karun adlawa nya mu refresh napud ang data within the next day.. any sample code for reference, need lang jud kaau
    Why don't you use javascript setInterval() function, and call your php script via ajax if the day has lapsed.

    <script type="text/javascript">
    setInterval(function() {
    // Call your php script here via ajax
    },
    10000); // Sample to update data every 10 seconds.

    </script>

  4. #4

    Default Inquiry

    Sir kolz can I ask your number, I need your help regarding of programs, mine 09175364810. tnx

  5. #5
    Quote Originally Posted by phantom007 View Post
    Sir kolz can I ask your number, I need your help regarding of programs, mine 09175364810. tnx
    I'm currently based in Singapore, pero ang concept about calling your php script is quite simple. I've attached sample code below where you can use sa imong project. You only require jQuery for ajax as the lone dependency:

    index.html

    HTML Code:
    <html>
    	<head>
    	</head>
    	<body>
    	<p>Current time is : <div id="timer"></div></p>
    	<p>Number of time updatetime() called: <div id="callcount"></div></p>
    	<p>
    	<hr/>
    	Database script is called every 20 seconds ...
    	Enter your name (becomes input to getdata.php): 
    	<input name="name" type="name" maxlength="50" id="getdataTxt" class="getdataInput"/>
    	<!-- This is the section where php script results will be displayed -->
    	<div id="databasereply">
    		<!-- Here we display the database table from php -->
    	</div>
    	<hr/>
    	</p>
    	</body>
    	<!-- Include scripts here ... -->
      <!-- Placed at the end of the document so the pages load faster -->
      <!-- Include JQuery (for ajax) -->
    	<!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.js"></script>  -->
    	<script type="text/javascript" src="jquery-3.1.1.min.js"></script>
    	<script type="text/javascript">
    		function setnewdaytimer()
    		{
      	  var now= new Date();
      	  // Set the alarm to next day (tomorrow)
        	var tomorrow= new Date(now.getFullYear(), now.getMonth(), now.getDate()+1); 
        	// Assign the callback function newdayalarm() if timer fires.
        	setTimeout(newdayalarm, tomorrow-now);
        	// We also want to update new time on the page every second
        	setInterval(ontimerupdate,1000); // 1000 = 1 second
        	// Call a php script every 20 seconds.
        	// To call the script once a day, then 2nd parameter would be
        	// 1000 * 60 * 60 * 24 -> which is 1000 (sec) * 60 (mins) * 60 (hr) * 24
        	setInterval(ondatabaseupdate, 1000 * 20); // 1 hr = 1000 * 60 (seconds) * 60 (minutes)
    		}
    		function newdayalarm(){
    			// Displays an alert box
        	alert((new Date()).toLocaleTimeString());
        	// TODO: Call php script via ajax
    		}
    		function ontimerupdate()
    		{
    			var today = new Date();
    			if (typeof ontimerupdate.count == 'undefined')
    			{
    				ontimerupdate.count = 0;
    			}
    			document.getElementById("timer").innerHTML = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
    			document.getElementById("callcount").innerHTML = ontimerupdate.count + "&nbsptimes!";
    			// increment counter
    			ontimerupdate.count ++;
    		}
    		function ondatabaseupdate()
    		{
    			var inputname = document.getElementById('getdataTxt').value;
    			if (!inputname || (0 === inputname.length))
    			{
    				inputname = "Istorya.net";
    			}
    			// Call your PHP script here (getdata.php) via ajax (JQuery)
    			// The result of getdata.php is stored as a JSON format
    			// where you can retrieve the text and display it on the
    			// html page	
    			var request = $.ajax({
    				type: "POST",
    				url: "getdata.php",
    				data: { name: inputname },
    				dataType: 'JSON',
    				success: function(datareply)
    				{
    						// Display the result of PHP script on the page
    						document.getElementById("databasereply").innerHTML = datareply.text;
    						console.log(datareply.text);
    				}
    			});
    		}
    		// Whe the web page loads, call the setnewdaytimer() function to
    		// set the timeout.
    		window.onload=setnewdaytimer;
    		
    	</script>
    </html>
    getdata.php
    PHP Code:
    <?php
            
    // A very simple PHP script, uses the variable 'name' from 
            // a POST request.
            
            // TODO: Do a database query through mysql, then store the result in
            // and array before encoding with json_encode()
        
    if(isset($_POST['name']) && !empty($_POST['name'])) {
              if (
    $_POST['name'] === "Rodrigo Duterte")
              {
                echo 
    json_encode(array("text" => "Welcome President ".$_POST['name']));
            }else
            {
                echo 
    json_encode(array("text" => "Welcome "$_POST['name'] . ", you low life son of a *!@#$!" ));
            }
        }
     
    ?>

    Ayaw kalimot ug download sa jQuery (".js") https://jquery.com/download/ script and put it on the same directory where the two files above reside.

  6. #6
    I just checked that latest script if there is a big need for that and it's indeed working fine so please let's make it possible within that task if you ask me. It doesn't matter in Singapore you are located or not, you need to have working software for your needs lately.

  7.    Advertisement

Similar Threads

 
  1. Replies: 37
    Last Post: 06-18-2015, 01:06 AM
  2. MOVED: LF: PHP and MYSQL Programmers - Website Development
    By chronnus in forum Websites & Multimedia
    Replies: 0
    Last Post: 10-05-2007, 03:22 PM
  3. PHP and MySQL Training
    By TaughtWorks in forum Programming
    Replies: 33
    Last Post: 10-02-2006, 04:12 PM
  4. PHP and MySQL
    By k3nt in forum Websites & Multimedia
    Replies: 11
    Last Post: 06-30-2006, 04:52 PM
  5. Independent contractor info needed---php and mysql
    By BayouPinoy in forum Networking & Internet
    Replies: 0
    Last Post: 03-17-2006, 10:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top