NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

test.php

<?php
$con=mysqli_connect("localhost","root","","sudipto2");

if(mysqli_connect_errno()){
echo "Failed to connect" . mysqli_connect_error();
}
else {
//echo "Successful";
}
?>



index2.php

<?php

include('test.php');

if(isset($_POST['Submit'])){
if(count($_POST['subjects'] > 0)){
//$car=implode(",",$_POST['subjects']);
//echo $car;exit;
$var='';
foreach($_POST['subjects'] as $acb){
$var .=$acb.',';
}
$var=rtrim($var,',');
}
$ins = "insert into admission set
name = '".$_POST['name']."',
gender = '".$_POST['gender']."',
address = '".$_POST['address']."',
phone_no = '".$_POST['phone_no']."',
subjects = '".$var."',
language = '".$_POST['language']."'";

if(mysqli_query($con,$ins)){
echo " Data Inserted";
}
else{
echo "Error" . mysqli_error($con);
}
}
?>

<form action="" method="POST">
<fieldset>

<b>Name</b>
<input type="text" name="name"><br><br>

<b>Gender</b><br>
<input type="radio" name="gender" value="1" checked>Male<br>
<input type="radio" name="gender" value="2">Female<br><br>

<b>Address</b>
<input type="text" name="address"><br><br>

<b>Phone No.</b>
<input type="int=15" name="phone_no"><br><br>

<b>Subjects</b>
<input type="checkbox" name="subjects[]" value="1">English</option>
<input type="checkbox" name="subjects[]" value="2">Maths</option>
<input type="checkbox" name="subjects[]" value="3">Science</option>
<input type="checkbox" name="subjects[]" value="4">Commerce</option><br><br>

<b>Second Language</b>
<select name="language">

<option value=""></option>
<option value="bengali">Bengali</option>
<option value="hindi">Hindi</option></select> <br><br>


<br><input type="submit" name="Submit" value="Submit"><br><br>
</fieldset>
</form>



list.php

<!DOCTYPE html>
<html>
<head>
<style>
th,td{
border: 1px solid black;
padding: 5x;
<!--border-collapse: collapse;-->
}
th,td{
text-align: center;
}
th{
background-color: black;
color: white;
}
</style>
</head>
<table style="width:50%">
<thead>

<caption>Details</caption>
<tr>
<th>Name</th>
<th>Gender</th>
<th>Address</th>
<th>Phone No.</th>
<th>Subjects</th>
<th>Language</th>
<th>Action</th>
</tr>
</thead>
<tbody>


<?php

include('test.php');

$sql= "select id, name, gender, address, phone_no, subjects, language from admission";
$result= mysqli_query($con, $sql);

if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result))
{


$div= (explode(",",$row['subjects']));
$ax='';
if(count($div) > 0){
foreach($div as $ty){
if ($ty == "1"){ $ax.= "English, ";}
elseif ($ty == "2"){ $ax.= "Maths, ";}
elseif ($ty == "3"){ $ax.= "Science, ";}
elseif ($ty == "4"){ $ax.= "Commerce, ";}
}
$ax=rtrim($ax,', ');
}
?>
<tr>
<td><?php echo $row["name"]?></td>
<td><?php if ($row["gender"] == "1"){ echo "Male";}
elseif ($row["gender"] == "2"){ echo "female";}
?></td>
<td><?php echo $row["address"]?></td>
<td><?php echo $row["phone_no"]?></td>
<td><?php echo $ax; ?></td>
<td><?php echo $row["language"]?></td>
<td><a href="edit.php?id=<?php echo $row['id']?>">Edit</a></td>
</tr>
<?php
}
} else {
echo "0 results";
}
?>
</tbody>
</table>
</html>



edit.php

<?php

include('test.php');
$qry= "select name, gender, address, phone_no, subjects, language from admission where id=$_GET[id]";
$result= mysqli_query($con, $qry);
$row1 = mysqli_fetch_array($result);
$subjects= explode(',', $row1['subjects']);
//print_r($subjects);

if(isset($_POST['Submit'])){
$upd_q = "update admission set
name = '".$_POST['name']."',
gender = '".$_POST['gender']."',
address = '".$_POST['address']."',
phone_no = '".$_POST['phone_no']."',
subjects = '".implode(',',$_POST['subjects'])."',
language = '".$_POST['language']."'
where id ='".$_GET['id']."'";

if(mysqli_query($con,$upd_q)){
echo " Data Inserted";
header('Location: list.php');
}
else{
echo "Error" . mysqli_error($con);
}
}
?>

<form action="" method="POST">
<fieldset>

<b>Name</b>
<input type="text" name="name" value="<?php echo $row1["name"]?>"><br><br>

<b>Gender</b><br>
<input type="radio" name="gender" value="1" <?php echo $row1['gender'] === '1' ? 'checked="checked"':'' ?>/>Male<br>
<input type="radio" name="gender" value="2" <?php echo $row1['gender'] === '2' ? 'checked="checked"':'' ?>/>Female<br><br>

<b>Address</b>
<input type="text" name="address" value="<?php echo $row1["address"]?>"><br><br>

<b>Phone No.</b>
<input type="int=15" name="phone_no" value="<?php echo $row1["phone_no"]?>"><br><br>

<b>Subjects</b>
<input type="checkbox" name="subjects[]" value="1" <?php if(in_array("1",$subjects)) {echo "checked='checked'";}?>/>English</option>
<input type="checkbox" name="subjects[]" value="2" <?php if(in_array("2",$subjects)) {echo "checked='checked'";}?>/>Maths</option>
<input type="checkbox" name="subjects[]" value="3" <?php if(in_array("3",$subjects)) {echo "checked='checked'";}?>/>Science</option>
<input type="checkbox" name="subjects[]" value="4" <?php if(in_array("4",$subjects)) {echo "checked='checked'";}?>/>Commerce</option><br><br>

<b>Second Language</b>
<select name="language">

<option <?php if ($row1["language"] == 'bengali' ) echo 'selected'; ?> value="bengali" >Bengali</option>
<option <?php if ($row1["language"] == 'hindi' ) echo 'selected' ; ?> value="hindi" >Hindi</option>


</select>

<br><br><input type="submit" name="Submit" value="Submit"><br><br>
</fieldset>
</form>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.