Php
1.prime
<html>
9. Develop a PHP code to read the values entered into the form using the MySQL database.
<html>
<center>
<form method="post">
Rollno:<input type="text" name="r"/><br><br>
name:<input type="text" name="n"/><br><br>
<input type="submit" value="INSERT"/>
</center>
</html>
<?php
$conn=mysqli_connect("localhost","root","", "bea123"); if(mysqli_connect_error())
die("connection failed");
else
{
echo("connection success");
if(S_POST)
{
Sm-S_POST['r'];
Snm-S POST['n'];
Ssql="insert into student (Rollno, name) values('Srn', 'Snm')";
Sres mysqli_query(Sconn, $sql);
if($res)
echo "<br> data insert successfully";
else
echo "<br> error in insertion";
}
}
?>
4. Develop a PHP program to demonstrate String functions. (any 6).
<?php
echo "Use of String Functions:\n",
$str1"Change Your thoughts and you will change the world!!!"; 5str2 "The first progranimer was women";
echo "The Given strings are:<br>"; echo "stringl is:" Sstri."<br>"; echo "string2 is:" Sstr2."<br><br>";
The PIIP strlen() function returns the length of a string. Slen strlen($str1); echo "The length of stri is: Slen;
The PIIP str_word_count() function counts the number of words in a string.
Sword_count str_word_count($str1); echo "<br>The Total words of strl is:" Sword_count;
//Convert the first character of each word to uppercase. Scapitalize ucwords($str1); echo "<br>The uppercase of each word is:\n" Scapitalize;
//Convert a string to uppercase letters.
Supper strtoupper($str1); echo"<br>The uppercase of string is:\n" Supper,
The PHP strrev() function reverses a string.
Sreverse strrev($str1);
echo "The reverse of string is:<br>". Sreverse;
"Comparing two strings."/Scompare stremp($str1,$str2); echo "<br> The comparision of str1 and str2 is:" Scompare;
//Repeating a string with a specific number of times.
Srepeate str repeat($str1,3);
echo "<br>".$repeate;
SNJPSNS TRUST'S DEGREE COLLEGE NIDASOSHI
Comments
Post a Comment