<?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>PHP Tutorials By Kloplop321 &#187; Deleting</title>
	<atom:link href="http://kloplop321.com/php-tutorials/index.php/tag/deleting/feed/" rel="self" type="application/rss+xml" />
	<link>http://kloplop321.com/php-tutorials</link>
	<description>PHP video tutorials, for everyone.</description>
	<lastBuildDate>Sun, 20 Mar 2011 19:03:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>MySQL and PHPMyAdmin Introduction with PHP 05</title>
		<link>http://kloplop321.com/php-tutorials/index.php/2009/12/26/mysql-and-phpmyadmin-introduction-with-php-05/</link>
		<comments>http://kloplop321.com/php-tutorials/index.php/2009/12/26/mysql-and-phpmyadmin-introduction-with-php-05/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 16:39:58 +0000</pubDate>
		<dc:creator>Kloplop321</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[PHPMyAdmin]]></category>
		<category><![CDATA[Select]]></category>
		<category><![CDATA[Deleting]]></category>

		<guid isPermaLink="false">http://kloplop321.com/php-tutorials/?p=158</guid>
		<description><![CDATA[In this tutorial I go over deleting rows, not only in PHPMyAdmin, but in PHP as well. Once rows are deleted, they are not coming back. On the side note, it is good to use something that is unique to every row when modifying them or deleting them. Otherwise you can delete anything that matches [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I go over deleting rows, not only in PHPMyAdmin, but in PHP as well. Once rows are deleted, they are not coming back. On the side note, it is good to use something that is unique to every row when modifying them or deleting them. Otherwise you can delete anything that matches the name being &#8220;orange&#8221; and delete two rows. This is why I usually always have an ID field in my rows.<br />
<object type="application/x-shockwave-flash" style="width:800px; height:472px;" data="http://kloplop321.com/php-tutorials/images/counter.swf"><param name="movie" value="http://kloplop321.com/php-tutorials/images/counter.swf" /><param name="allowFullScreen" value="true" /><param name="scale" value="noscale" /><param name="FlashVars" value="youtube=cnQmDYk3Pjs&amp;tutid=5&amp;part=1&amp;goals=How to delete rows in PHPMyAdmin and in PHP directly with MySQL&amp;vidpath=./tuts/vids/phpmyadmin05.mp4" />This video tutorial goes over how to select rows from a database in PHPMyAdmin and then in PHP and then process the rows individually. Also this goes over ordering(ORDER) and limitation(LIMIT) in the SQL.<br />
            	You can find this tutorial video on <a href="http://www.youtube.com/watch?v=cnQmDYk3Pjs">youtube here</a>.</object><br />
Source used after the jump;<br />
<span id="more-158"></span></p>
<pre><code><span class="webhtml1-mltag">&lt;?</span><span class="webhtml1-phpkeyword">php
$</span><span class="webhtml1-phpvariable">link</span><span class="webhtml1-phpwhitespace"> = </span><span class="webhtml1-phpfunction">mysql_connect</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpstring">'localhost'</span><span class="webhtml1-phpsymbol">, </span><span class="webhtml1-phpstring">'phpuser'</span><span class="webhtml1-phpsymbol">, </span><span class="webhtml1-phpstring">'phppass'</span><span class="webhtml1-phpsymbol">);
</span><span class="webhtml1-phpkeyword">if</span><span class="webhtml1-phpwhitespace"> (!</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">link</span><span class="webhtml1-phpsymbol">) {
    </span><span class="webhtml1-phpkeyword">die</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpstring">'Not connected : '</span><span class="webhtml1-phpwhitespace"> . </span><span class="webhtml1-phpfunction">mysql_error</span><span class="webhtml1-phpsymbol">());
}</span><span class="webhtml1-phpkeyword">else</span><span class="webhtml1-phpsymbol">{
    </span><span class="webhtml1-phpcomment">//echo &quot;I am connected. &quot;;
</span><span class="webhtml1-phpsymbol">}

</span><span class="webhtml1-phpcomment">// make foo the current db
</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">db_selected</span><span class="webhtml1-phpwhitespace"> = </span><span class="webhtml1-phpfunction">mysql_select_db</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpstring">'test'</span><span class="webhtml1-phpsymbol">, </span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">link</span><span class="webhtml1-phpsymbol">);
</span><span class="webhtml1-phpkeyword">if</span><span class="webhtml1-phpwhitespace"> (!</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">db_selected</span><span class="webhtml1-phpsymbol">) {
    </span><span class="webhtml1-phpkeyword">die</span><span class="webhtml1-phpwhitespace"> (</span><span class="webhtml1-phpstring">'Can</span><span class="webhtml1-phpstringspecial">\'</span><span class="webhtml1-phpstring">t use test : '</span><span class="webhtml1-phpwhitespace"> . </span><span class="webhtml1-phpfunction">mysql_error</span><span class="webhtml1-phpsymbol">());
}
</span><span class="webhtml1-phpkeyword">if</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpkeyword">isset</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">_REQUEST</span><span class="webhtml1-phpsymbol">[</span><span class="webhtml1-phpstring">'del'</span><span class="webhtml1-phpsymbol">])){
    </span><span class="webhtml1-phpcomment">//DELETE FROM `test`.`tableish` WHERE `tableish`.`ID` = 3
</span><span class="webhtml1-phpwhitespace">    </span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">id</span><span class="webhtml1-phpwhitespace"> = (</span><span class="webhtml1-phpkeyword">int</span><span class="webhtml1-phpsymbol">)</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">_REQUEST</span><span class="webhtml1-phpsymbol">[</span><span class="webhtml1-phpstring">'del'</span><span class="webhtml1-phpsymbol">];
    </span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">sql</span><span class="webhtml1-phpwhitespace"> = </span><span class="webhtml1-phpstring">&quot;DELETE FROM `tableish` WHERE `ID` = </span><span class="webhtml1-phpstringspecial">$id</span><span class="webhtml1-phpstring">&quot;</span><span class="webhtml1-phpsymbol">;
    </span><span class="webhtml1-phpfunction">mysql_query</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">sql</span><span class="webhtml1-phpsymbol">);
}
</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">sql</span><span class="webhtml1-phpwhitespace"> = </span><span class="webhtml1-phpstring">&quot;SELECT * FROM `tableish` ORDER BY `tableish`.`ID` ASC&quot;</span><span class="webhtml1-phpsymbol">;
</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">result</span><span class="webhtml1-phpwhitespace"> = </span><span class="webhtml1-phpfunction">mysql_query</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">sql</span><span class="webhtml1-phpsymbol">, </span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">link</span><span class="webhtml1-phpsymbol">);
</span><span class="webhtml1-phpkeyword">if</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpfunction">mysql_num_rows</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">result</span><span class="webhtml1-phpsymbol">) &gt; </span><span class="webhtml1-phpnumber">0</span><span class="webhtml1-phpsymbol">){
    </span><span class="webhtml1-phpkeyword">while</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">row</span><span class="webhtml1-phpwhitespace"> = </span><span class="webhtml1-phpfunction">mysql_fetch_array</span><span class="webhtml1-phpsymbol">(</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">result</span><span class="webhtml1-phpsymbol">)){
        </span><span class="webhtml1-phpkeyword">echo</span><span class="webhtml1-phpwhitespace"> </span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">row</span><span class="webhtml1-phpsymbol">[</span><span class="webhtml1-phpstring">'name'</span><span class="webhtml1-phpsymbol">].</span><span class="webhtml1-phpstring">&quot;&lt;a href=</span><span class="webhtml1-phpstringspecial">\&quot;</span><span class="webhtml1-phpstring">?del=&quot;</span><span class="webhtml1-phpsymbol">.</span><span class="webhtml1-phpkeyword">$</span><span class="webhtml1-phpvariable">row</span><span class="webhtml1-phpsymbol">[</span><span class="webhtml1-phpstring">'ID'</span><span class="webhtml1-phpsymbol">].</span><span class="webhtml1-phpstring">&quot;</span><span class="webhtml1-phpstringspecial">\&quot;</span><span class="webhtml1-phpstring">&gt;Delete this row&lt;/a&gt;&lt;br /&gt;</span><span class="webhtml1-phpstringspecial">\n</span><span class="webhtml1-phpstring">&quot;</span><span class="webhtml1-phpsymbol">;
    }
}

</span><span class="webhtml1-mltag">?&gt;
</span></code></pre>
]]></content:encoded>
			<wfw:commentRss>http://kloplop321.com/php-tutorials/index.php/2009/12/26/mysql-and-phpmyadmin-introduction-with-php-05/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

