Find out the Value in Table

Posted on Updated on

Find out the Value in Table

How can we find the exist and not inserted value into the table?

Many time what happing we insert the value into the table we want the value must be unique like a phone number we want only one phone is attaché only so we use the unique key into the table but the problem is that If the value is available already its not show the value is exist to find the value is exist or not we are use the PHP 5 function mysqli_affected_rows.

It’s return the value of rows effected when we insert the values.if the row effected means data is insert then it show the answer 1 and if row is not effected it show the output -1.

Now the question how to use it.

Create a form to insert the value

<form action=”<?php echo $_SERVER[‘PHP_SELF’];?>” method=”post”>

<input type=”text” name=”p_num” placeholder=”Enter your phone number”/>

<input type=”submit” name=”submit” value=”save!”/>

</form>

Now PHP

First click on button set the value

If(isset($_POST[‘submit’])){

Create a connection between database and php

$con=mysqli_connect(“localhost”,”root”,””,”job_portal_database”);

Fetch the value from the html with help of name

$pnum=$_POST[‘p_num’];

Now write the query

Now user the row affected by the query and save it into a variable

Now check the condition of row effected if the value is -1 then no row is effected if 1 then data is

inserted

Now close the connection

}?>

For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.

Helpline: 9814666333, 8699444666

Email:info@technocampus.co.in

**************************************************************************************************************

Please fill the FORM and we shall contact you soon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s