File "test01.php"

Full Path: /home/analogde/www/Prog/MMM/Fusion/test01.php
File size: 4.78 KB
MIME-type: text/html
Charset: utf-8

 <?php 
 
	if (isset($_POST['form_submitted'])) 
	{
		echo "lulu....";
		//$_POST['form_submitted']  = 0;
		
		$connection = mysqli_connect("localhost", "root", "","database");

		$size=sizeof($_POST);
		$number=$size/3;

		for($i=1;$i<=$number;$i++)
		{
			$numberone="columnone".$i;
			$first[$i]=$_POST[$numberone];
			$numbertwo="columntwo".$i;
			$second[$i]=$_POST[$numbertwo];
			$numberthree="columnthree".$i;
			$third[$i]=$_POST[$numberthree];
		}
		
		print_r($first);
		
		echo "<br>";
		
		echo $first[1];
		
		echo "<br>";
		
		echo gettype($first[1]);
		
		$string = $first[1];
		
		// check contents of input in "real time"
		
		//https://stackoverflow.com/questions/43050218/how-to-check-contents-of-input-in-real-time
		
		// https://awik.io/allow-numbers-input-field-javascript/   ++++++
		
		if ( is_numeric( $first[1] ) ) 
		{
			echo "\"{$string}\" is a number.";
		} 
		else
		{
			echo "\"{$string}\" is not a number.";
		}
		
		// $final_value = number_format($value, 1);
//var val = document.getElementById("my_input").getAttribute("value");
		// php save html table in mysql database
		
		//https://talkerscode.com/howto/how-to-insert-html-table-data-into-database-using-php.php
		
		/*for($i=1;$i<=$number;$i++)
		{
			$query = "Insert into table_name (one,two,three) values ('$first[$i]','$second[$i]','$three[$i]')";
			if( mysqli_query($connection , $query))
			{
				echo “ Data Inserted Successfully”;
			}
		}*/
		
	}


?>


<!DOCTYPE html>
<html lang="en">
<head>
    <title> TalkersCode </title>
	
	
	<script>
	
	
	var inputField = document.querySelector('#numbers-only');

inputField.onkeydown = function(event) {
  // Only allow if the e.key value is a number or if it's 'Backspace'
  if(isNaN(event.key) && event.key !== 'Backspace') {
    event.preventDefault();
  }
};
	
	// https://linuxhint.com/force-input-field-to-only-numbers-javascript/
	function checkNumber(event) {

var aCode = event.which ? event.which : event.keyCode;

if (aCode > 31 && (aCode < 48 || aCode > 57)) return false;

return true;

}
	
	
	function myFunction() 
{
  //document.getElementById("myCheck").click();
  alert("bingo");
  
    var x = document.getElementsByName('columnone1')[0].value;
    document.getElementById("demo").innerHTML = x;

  
  }
  
  
	function Function() 
	{
		alert("onblur");
		//let x = document.getElementById("fname");
		//x.value = x.value.toUpperCase();
	}
  
	function test_input()
	{
		//var titi = document.getElementByName("columnone1").value;
	
		//alert("cretin");
		
		//https://jsfiddle.net/KarmaProd/tgn9d1uL/4/
		
		// https://awik.io/allow-numbers-input-field-javascript/
		
		var x = document.getElementsByName('columnone1')[0].value;
		
		alert(x);
		
		/*if (res != '') 
		{
                if (isNaN(res))
				{
				}
		}		
 */
	
		//var div = document.getElementById('myDiv');
      //div.innerHTML += 'WayToLearnX!';
	
	}

	
	</script>
	
</head>
<body>
<form action="" method="post">
<table border="2px" >
<tr>
<th>Column one</th>
<th> Column Two</th>
<th> Column Three </th>
</tr>

<!-- onblur  
onblur="myFunction()

-->

<?php
for($i=1;$i<=7;$i++)
{
?>
<tr>
<td>
<!--

// https://www.geeksforgeeks.org/how-to-force-input-field-to-enter-numbers-only-using-javascript/

//https://www.geeksforgeeks.org/implement-a-javascript-when-an-element-loses-focus/

<input type="text" name="columnone<?php echo $i; ?>"  onmouseover="myFunction()" onclick="alert('click event occurred')" />

<input type="text" name="columnone<?php echo $i; ?>"  onblur="Function()"  />
-->

<input type="text" name="columnone<?php echo $i; ?>"  oninput="test_input()"  />


</td>
<td>
<input type="text" name=" columntwo<?php echo $i;?>" onmouseover="myFunction()" onclick="alert('click event occurred')" />
</td>
<td>
<input type="text" name=" columnthree<?php echo $i;?>" onmouseover="myFunction()" onclick="alert('click event occurred')" />
</td>
</tr>
<?php
}
?>
</table>

<input type="hidden" name="form_submitted" value="1" />

<input type="submit" value="Submit"/>

</form>

<input type="text" name="passkey" id="num"  oninput="return onlynum()" minlength="2">


<input id="numbers-only" type="text" placeholder="Numbers Only" />

<input type="text" onkeypress="return checkNumber(event)" />

<!--  https://net-informations.com/js/progs/num.htm --> 

<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');" />

 <div id="myDiv"></div>

 <!-- https://webdevpuneet.com/how-to-allow-only-numeric-digits-in-an-input-field/#gsc.tab=0 --> 
 <!-- https://www.vrsofttech.com/code-editor/js/index?file_name=js-allow-only-numbers -->
 <!-- https://copyprogramming.com/howto/allow-only-numbers-in-input-text-box -->
 
 <!-- https://www.techiedelight.com/restrict-html-input-text-box-to-allow-only-numeric-values/ -->
 
 <!-- https://www.w3resource.com/javascript/form/all-numbers.php -->
 
</body>
</html>