<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>View records using php Archives -</title>
	<atom:link href="https://mitindia.in/tag/view-records-using-php/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/view-records-using-php/</link>
	<description></description>
	<lastBuildDate>Sat, 26 Nov 2016 07:19:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mitindia.in/wp-content/uploads/2023/03/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>View records using php Archives -</title>
	<link>https://mitindia.in/tag/view-records-using-php/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Display and Update records using PHP</title>
		<link>https://mitindia.in/display-and-update-records-using-php/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Wed, 22 Jun 2016 10:01:55 +0000</pubDate>
				<category><![CDATA[PHP-MySQL]]></category>
		<category><![CDATA[View records using php]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=125</guid>

					<description><![CDATA[<p>In this tutorials you&#8217;ll able to List / Display records and Update records using PHP program with MySQL as a back-end database. First of all we will display list of all records entered into MySQL database using PHP page. Here is the code for that. 1. File name : list_records.php &#60;?php $host="localhost"; $username="root"; $password=""; $db_name="mars_db"; [&#8230;]</p>
<p>The post <a href="https://mitindia.in/display-and-update-records-using-php/">Display and Update records using PHP</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this tutorials you&#8217;ll able to List / Display records and Update records using PHP program with MySQL as a back-end database.</p>
<p>First of all we will display list of all records entered into MySQL database using PHP page. Here is the code for that.</p>
<p>1. File name : <strong>list_records.php</strong></p>
<pre>&lt;?php
$host="localhost"; 
$username="root";
$password=""; 
$db_name="mars_db"; 
$tbl_name="list"; 

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?&gt;

&lt;h1&gt; Update records &lt;/h1&gt; &lt;hr color="yellow"&gt;
&lt;table width="400" border="0" cellspacing="1" cellpadding="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;table width="400" border="1" cellspacing="0" cellpadding="3"&gt;
&lt;tr&gt;
&lt;td colspan="4"&gt;&lt;strong&gt;List of Employee Records &lt;/strong&gt; &lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td align="center"&gt;&lt;strong&gt;ID&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;First name&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Last Name&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;?php
while($rows=mysql_fetch_array($result)){
?&gt;

&lt;tr&gt;
&lt;td&gt;&lt;?php echo $rows['id']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $rows['fname']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $rows['lname']; ?&gt;&lt;/td&gt;


&lt;td align="center"&gt;&lt;a href="update.php?id=&lt;?php echo $rows['id']; ?&gt;"&gt;update&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;?php
}
?&gt;

&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;?php
mysql_close();
?&gt;
&lt;img src=icons/k.png&gt;
&lt;img src=icons/b.png&gt;
&lt;img src=icons/y.png&gt;</pre>
<p>2. Out put from above code looks as following.</p>
<div class="separator"><img fetchpriority="high" decoding="async" class="alignnone" src="http://2.bp.blogspot.com/-_aPA1juninw/VpY7yTukEDI/AAAAAAAABGk/nxcR4vZAh9E/s1600/list_records.JPG" width="481" height="436" border="0" /></div>
<p>3. Now, copy the below code and save as &#8220;update.php&#8221;.</p>
<pre>&lt;?php
$host="localhost"; 
$username="root";
$password=""; 
$db_name="mars_db"; 
$tbl_name="list"; 

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$id=$_GET['id'];

$sql="SELECT * FROM $tbl_name WHERE id='$id'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
?&gt;

&lt;table width="400" border="0" cellspacing="1" cellpadding="0"&gt;
&lt;tr&gt;
&lt;form name="form1" method="post" action="update_ac.php"&gt;
&lt;td&gt;
&lt;table width="100%" border="0" cellspacing="1" cellpadding="0"&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td colspan="3"&gt;&lt;strong&gt;Update data in mysql&lt;/strong&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;ID&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;First Name&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Last Name&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;
&lt;input name="id" type="text" id="id" value="&lt;?php echo $rows['id']; ?&gt;"&gt;
&lt;/td&gt;
&lt;td align="center"&gt;
&lt;input name="fname" type="text" id="fname" value="&lt;?php echo $rows['fname']; ?&gt;" size="15"&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;input name="lname" type="text" id="lname" value="&lt;?php echo $rows['lname']; ?&gt;" size="15"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;
&lt;input name="id" type="hidden" id="id" value="&lt;?php echo $rows['id']; ?&gt;"&gt;
&lt;/td&gt;
&lt;td align="center"&gt;
&lt;input type="submit" name="Submit" value="Submit"&gt;
&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/form&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;?php
mysql_close();
?&gt;</pre>
<p>4. The out put of the above file looks as below.</p>
<div class="separator"><img decoding="async" class="alignnone" src="http://1.bp.blogspot.com/-OTaf4DeLkfI/VpY8bW3J3pI/AAAAAAAABGs/hh7HboI6-lw/s1600/update.JPG" width="481" height="227" border="0" /></div>
<p>5. When you want to update, just click on Submit button and it will take you to next page called &#8220;update_ac.php&#8221;, refer the below code.</p>
<pre>&lt;?php
$id=$_POST["id"];
$fname=$_POST["fname"];
$lname=$_POST["lname"];

$host="localhost"; 
$username="root";
$password=""; 
$db_name="mars_db"; 
$tbl_name="list"; 

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="UPDATE $tbl_name SET fname='$fname', lname='$lname' WHERE id='$id'";
$result=mysql_query($sql);

if($result)
{
echo "Successful";
echo "&lt;BR&gt;";
echo "&lt;a href='list_records.php'&gt;View result&lt;/a&gt;";
}

else 
{
echo "ERROR";
}
?&gt;</pre>
<p>6. The above code is having following output.</p>
<div class="separator"><img decoding="async" class="alignnone" src="http://1.bp.blogspot.com/-Z7xUhZiUBU4/VpY9LYalwDI/AAAAAAAABG0/CAUYV6NKQH0/s1600/confirm.JPG" width="482" height="150" border="0" /></div>
<p>7. once you click on &#8220;View result&#8221; link as per above image, it will redirect to the &#8220;list_records.php&#8221;, hence you&#8217;ll have updated records.</p>
<p>Thank you for reading and referring my blog. Keep reading mitindia.in for latest updates and don&#8217;t forget to subscribe!</p>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fdisplay-and-update-records-using-php%2F&amp;linkname=Display%20and%20Update%20records%20using%20PHP" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fdisplay-and-update-records-using-php%2F&amp;linkname=Display%20and%20Update%20records%20using%20PHP" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fdisplay-and-update-records-using-php%2F&#038;title=Display%20and%20Update%20records%20using%20PHP" data-a2a-url="https://mitindia.in/display-and-update-records-using-php/" data-a2a-title="Display and Update records using PHP"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/display-and-update-records-using-php/">Display and Update records using PHP</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
