Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Floyd’s Triangle with 13 Range Program in PHP

Floyd’s Triangle with 13 Range Program in PHP

In this tutorial, we will try to learn the Floyd’s Triangle with 13 Range Program in PHP.

Floyd’s Triangle with 13 Range Program in PHP

Here, there is a code of the Floyd’s Triangle with 13 Range Program in PHP.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
echo "<h1>Follwing is floyd's Triangle with 13 Range</br></br>";
echo "<pre>";
$val= 1;
for ($x = 1; $x <= 13; $x++) {
    for ($j = 1; $j <= $x; $j++) {
        echo $val . "&nbsp;";
        $val++;
        if ($j == $x) {
            echo "&nbsp;";
            echo "<br/>";
        }
    }
}
echo "</pre>";
?>
</body>
</html>

Floyd’s Triangle with 13 Range Program with the database in PHP and MySQL

Here, there is a code of the Floyd’s Triangle with 13 Range Program in PHP with MySQL database.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHP Script to Print Floyd's Traingle</title>
</head>
<body>
<h3>PHP Script to print Floyd's Traingle</h3>
<form method="post">
Enter the Limit: <input type="text" name="choice" /> 
<input type="submit" value="Floyd's Traingle range please" /><br /><br />
</form>
</body>
</html>
<?php
$con=mysqli_connect("localhost","root","","floyd limit");
if(isset($_POST['choice']) && $_POST['choice'])
{
	$range = $_POST['choice'];
	$x = 1;
	
	for ($i = 1; $i <= $range; $i++)
		{
		for ($c = 1; $c <= $i; $c++)
		{
			$x.' ';
			$x++;
			$sql=mysql_query($con,"INSERT INTO data_limit(range_limit) 
VALUES('$range')");
		}	

	}
}
?>
<?php
		$con=mysqli_connect("localhost","root","","floyd limit");
		if(isset($_POST['OK']))
?>

Database View

here, there is a database View of the code of Floyd’s Triangle with 13 Range Program in PHP.

Floyd's Triangle with 13 Range Program in PHP

Figure: Floyd’s Triangle with 13 Range Program in PHP

 

Fazal Rehman Shamil Click Here to Know More
Instructor, Researcher, Blogger, SEO Expert, Poet and Publisher of International Journal Of Software, Technology & Science ISSN : 2616 - 5325
Dear Professors and Resarchers!You are welome to Cite these tutorials in your research or slides etc. Please don't forget to mention the reference of website. Copy Paste of text is strcitly forbidden. Images can be reuse because images are protected with watermark.