<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    
    <title>Learning PHP and MySQL</title>
    <link>http://www.krautgrrl.com/learningphp/index.php/site/index/</link>
    <description></description>
    <dc:language>en</dc:language>
    <dc:creator>michele@krautgrrl.com</dc:creator>
    <dc:rights>Copyright 2006</dc:rights>
    <dc:date>2006-09-27T18:39:00-06:00</dc:date>
    <admin:generatorAgent rdf:resource="http://www.pmachine.com/" />
    

    <item>
      <title>Welcome to the O&#8217;Reilly Learning PHP &amp; MySQL blog</title>
      <link>http://www.krautgrrl.com/learningphp/index.php/site/welcome_to_the_oreilly_learning_php_mysql_blog/</link>
      <guid>http://www.krautgrrl.com/learningphp/index.php/site/welcome_to_the_oreilly_learning_php_mysql_blog/#When:17:58:00Z</guid>
      <description>Here you will find code directly from the book, error listings, code fixes, and trivia about the computing world. Welcome. The authors of Learning PHP &amp; MySQL Michele Davis and Jon Phillips will also be happy to answer any questions. So please use your real name when signing in! We look forward to a lively blog with lots of comments!


Source code for each chapter is posted under the catagories on the right side bar.</description>
      <dc:subject>Blogging</dc:subject>
      <dc:date>2006-07-06T17:58:00-06:00</dc:date>
    </item>

    <item>
      <title>Example 17&#45;2 Function comments</title>
      <link>http://www.krautgrrl.com/learningphp/index.php/site/example_17_2_function_comments/</link>
      <guid>http://www.krautgrrl.com/learningphp/index.php/site/example_17_2_function_comments/#When:18:39:00Z</guid>
      <description>/**&#160;&#160;furniture&#160;&#160;stores&#160;&#160;locator.*&#160;&#160;Locate&#160;&#160;furniture&#160;&#160;stores&#160;&#160;in&#160;&#160;Minnesota,&#160;&#160;Wisconsion,&#160;&#160;Iowa&#160;&#160;and*&#160;&#160;Illinois&#160;&#160;based&#160;&#160;on&#160;&#160;their&#160;&#160;zip&#160;&#160;code.**&#160;&#160;@author&#160;&#160;&#160;&#160;michele&#160;&#160;davis&#160;&#160;mdavis@example.com*&#160;&#160;@param&#160;&#160;&#160;&#160;zipcode&#160;&#160;&#160;&#160;the&#160;&#160;zipcode&#160;&#160;to&#160;&#160;search&#160;&#160;for&#160;&#160;stores&#160;&#160;near*&#160;&#160;@return&#160;&#160;&#160;&#160;store&#160;&#160;&#160;&#160;the&#160;&#160;store&#160;&#160;id&#160;&#160;of&#160;&#160;the&#160;&#160;nearest&#160;&#160;store*&#160;&#160;@date&#160;&#160;&#160;&#160;2005&#45;12&#45;21**/</description>
      <dc:subject>Chapter 17 Code</dc:subject>
      <dc:date>2006-09-27T18:39:00-06:00</dc:date>
    </item>

    <item>
      <title>Example 17&#45;1 File comments</title>
      <link>http://www.krautgrrl.com/learningphp/index.php/site/example_17_1_file_comments/</link>
      <guid>http://www.krautgrrl.com/learningphp/index.php/site/example_17_1_file_comments/#When:18:36:01Z</guid>
      <description>/***&#160;&#160;this&#160;&#160;file&#160;&#160;is&#160;&#160;about&#160;&#160;furniture&#160;&#160;stores.*&#160;&#160;this&#160;&#160;file&#160;&#160;is&#160;&#160;about&#160;&#160;furniture&#160;&#160;stores&#160;&#160;in&#160;&#160;Minnesota,&#160;&#160;Wisconsion,&#160;&#160;Iowa&#160;&#160;and&#160;&#160;Illinois.**&#160;&#160;Portions&#160;&#160;Copyright&#160;&#160;2005&#45;2006&#160;&#160;(c)&#160;&#160;O’Reilly&#160;&#160;&amp;&#160;&#160;Associates*&#160;&#160;The&#160;&#160;rest&#160;&#160;Copyright&#160;&#160;2005&#160;&#160;(c)&#160;&#160;from&#160;&#160;their&#160;&#160;respective&#160;&#160;authors**&#160;&#160;@version&#160;&#160;&#160;&#160;$Id:&#160;&#160;coding_standards.html,v&#160;&#160;1.2&#160;&#160;2005/12/19&#160;&#160;24:49:50**/</description>
      <dc:subject>Chapter 17 Code</dc:subject>
      <dc:date>2006-09-27T18:36:01-06:00</dc:date>
    </item>

    <item>
      <title>Example 16&#45;17 comment_form.tpl</title>
      <link>http://www.krautgrrl.com/learningphp/index.php/site/example_16_17_comment_formtpl/</link>
      <guid>http://www.krautgrrl.com/learningphp/index.php/site/example_16_17_comment_formtpl/#When:18:36:00Z</guid>
      <description>&#123;section&#160;&#160;name=mysec&#160;&#160;loop=$comments&#125;&lt;form&#160;&#160;action=&quot;modify_comment.php&quot;&#160;&#160;method=&quot;post&quot;&gt;&lt;label&gt;&#160;Title:&lt;input&#160;&#160;type=&quot;text&quot;&#160;&#160;name=&quot;title&quot;&#160;&#160;value=&quot;&#123;$comments&#91;mysec&#93;.title&#125;&quot;&#160;&#160;/&gt;&lt;/label&gt;&lt;br&#160;&#160;/&gt;&lt;br&#160;&#160;/&gt;&lt;label&gt;&#160;Body:&lt;textarea&#160;&#160;name=&quot;body&quot;&#160;&#160;cols=&quot;40&quot;&#160;&#160;rows=&quot;4&quot;&gt;&#123;$comments&#91;mysec&#93;.body&#125;&lt;/textarea&gt;&lt;/label&gt;&lt;input&#160;&#160;type=&quot;hidden&quot;&#160;&#160;name=&quot;action&quot;&#160;&#160;value=&quot;&#123;$action&#125;&quot;&#160;&#160;/&gt;&lt;input&#160;&#160;type=&quot;hidden&quot;&#160;&#160;name=&quot;post_id&quot;&#160;&#160;value=&quot;&#123;$post_id&#125;&quot;&#160;&#160;/&gt;&lt;input&#160;&#160;type=&quot;hidden&quot;&#160;&#160;name=&quot;comment_id&quot;&#160;&#160;value=&quot;&#123;$comments&#91;mysec&#93;.comment_id&#125;&quot;&#160;&#160;/&gt;&lt;br&#160;&#160;/&gt;&lt;br&#160;&#160;/&gt;&lt;input&#160;&#160;type=&quot;submit&quot;&#160;&#160;name=&quot;submit&quot;&#160;&#160;value=&quot;Post&quot;&#160;&#160;/&gt;&lt;/form&gt;&#123;/section&#125;</description>
      <dc:subject>Chapter 16 Code</dc:subject>
      <dc:date>2006-09-27T18:36:00-06:00</dc:date>
    </item>

    <item>
      <title>Example 16&#45;16 modify_comment.php</title>
      <link>http://www.krautgrrl.com/learningphp/index.php/site/example_16_16_modify_commentphp/</link>
      <guid>http://www.krautgrrl.com/learningphp/index.php/site/example_16_16_modify_commentphp/#When:18:25:00Z</guid>
      <description>&lt;?php&#160;session_start();require_once(&apos;config.php&apos;);&#160;require_once(&apos;db_login.php&apos;);&#160;require_once(&quot;DB.php&quot;);//&#160;&#160;Display&#160;&#160;the&#160;&#160;header$smarty&#45;&gt;assign(&apos;blog_title&apos;,$blog_title);$smarty&#45;&gt;display(&apos;header.tpl&apos;);//&#160;&#160;Check&#160;for&#160;valid&#160;loginif&#160;&#160;(!isset($_SESSION&#91;&quot;username&quot;&#93;))&#160;&#160;&#123;echo&#160;&apos;Please&#160;&lt;a&#160;&#160;href=&quot;login.php&quot;&gt;login&lt;/a&gt;.&apos;;exit;&#125;//&#160;&#160;Connect&#160;to&#160;the&#160;database$connection&#160;=&#160;DB::connect(&quot;mysql://$db_username:$db_password@$db_host/$db_database&quot;);if&#160;&#160;(DB::isError($connection))&#123;die&#160;&#160;(&quot;Could&#160;not&#160;connect&#160;to&#160;the&#160;database:&#160;&lt;br&#160;&#160;/&gt;&quot;.&#160;DB::errorMessage($connection));&#125;$stop&#160;=&#160;false;$post_id&#160;&#160;=&#160;&#160;$_REQUEST&#91;&quot;post_id&quot;&#93;;$title&#160;=&#160;htmlentities($_POST&#91;&apos;title&apos;&#93;);$body&#160;=&#160;htmlentities($_POST&#91;&apos;body&apos;&#93;);$action&#160;=&#160;htmlentities($_POST&#91;&apos;action&apos;&#93;);$category_id&#160;=&#160;htmlentities($_POST&#91;&apos;category_id&apos;&#93;);$user_id&#160;=&#160;$_SESSION&#91;&quot;user_id&quot;&#93;;$comment_id&#160;=&#160;htmlentities($_POST&#91;&apos;comment_id&apos;&#93;);if&#160;&#160;($_GET&#91;&apos;action&apos;&#93;&#160;==&#160;&quot;delete&quot;&#160;and&#160;!$stop)&#160;&#160;&#123;$comment_id&#160;=&#160;$_GET&#91;&quot;comment_id&quot;&#93;;$query&#160;=&#160;&quot;DELETE&#160;&#160;FROM&#160;&#160;`comments`&#160;&#160;WHERE&#160;&#160;`comment_id`=&apos;&quot;.$comment_id.&quot;&apos;&#160;AND&#160;&#160;`user_id`=&apos;&quot;.$user_id.&quot;&apos;&quot;;$result&#160;=&#160;$connection&#45;&gt;query($query);if&#160;(DB::isError($result))&#123;die(&quot;Could&#160;&#160;not&#160;&#160;query&#160;&#160;the&#160;&#160;database:&#160;&#160;&lt;br&#160;&#160;/&gt;&quot;.$query.&quot;&#160;&#160;&quot;.DB::errorMessage($result));&#125;echo&#160;&quot;Deleted&#160;successfully.&lt;br&#160;&#160;/&gt;&quot;;$stop&#160;=&#160;true;&#125;//&#160;We&apos;re&#160;editing&#160;an&#160;entry,&#160;explicitly&#160;grab&#160;the&#160;id&#160;from&#160;the&#160;URLif&#160;($_GET&#91;&quot;comment_id&quot;&#93;&#160;and&#160;!$stop)&#160;&#160;&#123;$query&#160;&#160;=&#160;&#160;&quot;SELECT&#160;*&#160;FROM&#160;`comments`&#160;NATURAL&#160;JOIN&#160;`users`WHERE&#160;`comment_id`=&quot;.$_GET&#91;&quot;comment_id&quot;&#93;;$result&#160;&#160;=&#160;&#160;$connection&#45;&gt;query($query);if&#160;&#160;(DB::isError($result))&#123;die(&quot;Could&#160;not&#160;query&#160;the&#160;database:&#160;&lt;br&#160;&#160;/&gt;&quot;.$query.&quot;&#160;&#160;&quot;.DB::errorMessage($result));&#125;while&#160;&#160;($result_row&#160;&#160;=&#160;&#160;$result&#45;&gt;fetchRow(DB_FETCHMODE_ASSOC))&#160;&#160;&#123;$comments&#91;&#93;&#160;&#160;=&#160;&#160;$result_row;&#125;$post_id&#160;&#160;=&#160;&#160;$_GET&#91;&quot;post_id&quot;&#93;;$smarty&#45;&gt;assign(&apos;action&apos;,&apos;edit&apos;);$smarty&#45;&gt;assign(&apos;comments&apos;,$comments);$smarty&#45;&gt;assign(&apos;post_id&apos;,$post_id);$smarty&#45;&gt;display(&apos;comment_form.tpl&apos;);//&#160;&#160;Display&#160;the&#160;footer$smarty&#45;&gt;display(&apos;footer.tpl&apos;);exit;&#125;//The&#160;form&#160;was&#160;submitted,&#160;was&#160;itan&#160;add&#160;or&#160;an&#160;update?if&#160;($_POST&#91;&apos;submit&apos;&#93;&#160;&#160;and&#160;&#160;!$stop)&#160;&#160;&#123;//&#160;Validate&#160;fields&#160;if&#160;&#160;($title&#160;&#160;==&#160;&#160;&quot;&quot;)&#123;echo&#160;&#160;&apos;Title&#160;must&#160;not&#160;be&#160;null.&lt;br&#160;&#160;/&gt;&apos;;$found_error&#160;&#160;=&#160;&#160;true;$stop&#160;&#160;=&#160;&#160;true;&#125;if&#160;&#160;($body&#160;&#160;==&#160;&#160;&quot;&quot;)&#123;echo&#160;&#160;&quot;Body&#160;must&#160;not&#160;be&#160;null.&lt;br&#160;&#160;/&gt;&quot;;$found_error&#160;=&#160;true;$stop&#160;=&#160;true;&#125;//&#160;Validated&#160;OK&#160;lets&#160;hit&#160;the&#160;databaseif&#160;&#160;($_POST&#91;&apos;action&apos;&#93;&#160;==&#160;&quot;add&quot;&#160;AND&#160;!$stop)&#160;&#123;$query&#160;&#160;=&#160;&#160;&quot;INSERT&#160;INTO&#160;`comments`&#160;VALUES&#160;(NULL,&apos;&quot;.$user_id.&quot;&apos;,&apos;&quot;.$post_id.&quot;&apos;,&apos;&quot;.$title.&quot;&apos;,&apos;&quot;.$body.&quot;&apos;,&#160;&#160;NULL)&quot;;$result&#160;&#160;=&#160;&#160;$connection&#45;&gt;query($query);if&#160;&#160;(DB::isError($result))&#123;die(&quot;Could&#160;not&#160;query&#160;the&#160;database:&#160;&lt;br&#160;&#160;/&gt;&quot;.$query.&quot;&#160;&#160;&quot;.DB::errorMessage($result));&#125;echo&#160;&quot;Posted&#160;successfully.&lt;br&#160;&#160;/&gt;&quot;;$stop&#160;=&#160;true;&#125;if&#160;($_POST&#91;&apos;action&apos;&#93;==&quot;edit&quot;&#160;and&#160;!$stop)&#123;$query&#160;=&#160;&quot;UPDATE&#160;`comments`&#160;SET`title`=&apos;&quot;.$title.&quot;&apos;,`body`=&apos;&quot;.$body.&quot;&apos;WHERE&#160;`comment_id`=&apos;&quot;.$comment_id.&quot;&apos;&#160;AND&#160;`user_id`=&apos;&quot;.$user_id.&quot;&apos;&quot;;$result&#160;&#160;=&#160;&#160;$connection&#45;&gt;query($query);if&#160;(DB::isError($result))&#123;die(&quot;Could&#160;not&#160;query&#160;the&#160;database:&#160;&lt;br&#160;&#160;/&gt;&quot;.$query.&quot;&#160;&quot;.DB::errorMessage($result));&#125;echo&#160;&apos;Updated&#160;successfully.&lt;br&#160;&#160;/&gt;&apos;;$stop&#160;=&#160;true;&#125;&#125;if&#160;&#160;(!$stop)&#123;//&#160;&#160;Display&#160;blank&#160;form//&#160;Create&#160;an&#160;empty&#160;entry$post_id&#160;=&#160;$_GET&#91;&quot;post_id&quot;&#93;;$result_row&#160;=&#160;array(&apos;title&apos;=&gt;NULL,&apos;body&apos;=&gt;NULL,&apos;comment_id&apos;=&gt;NULL);$comments&#91;&#93;&#160;=&#160;$result_row;//&#160;Get&#160;the&#160;categories$smarty&#45;&gt;assign(&apos;post_id&apos;,$post_id);$smarty&#45;&gt;assign(&apos;comments&apos;,$comments);$smarty&#45;&gt;assign(&apos;action&apos;,&apos;add&apos;);$smarty&#45;&gt;display(&apos;comment_form.tpl&apos;);&#125;if&#160;&#160;($found_error)&#160;&#160;&#123;//&#160;&#160;Assign&#160;old&#160;vals//&#160;Redisplay&#160;form$post_id&#160;=&#160;$_POST&#91;&quot;post_id&quot;&#93;;$result_row&#160;=&#160;array(&apos;title&apos;=&gt;&quot;$title&quot;,&apos;body&apos;=&gt;&quot;$body&quot;,&apos;comment_id&apos;=&gt;&quot;$comment_id&quot;);$comments&#91;&#93;&#160;=&#160;$result_row;$smarty&#45;&gt;assign(&apos;action&apos;,$action);$smarty&#45;&gt;assign(&apos;post_id&apos;,$post_id);$smarty&#45;&gt;assign(&apos;comments&apos;,$comments);$smarty&#45;&gt;display(&apos;comment_form.tpl&apos;);&#125;//&#160;&#160;Display&#160;the&#160;footer$smarty&#45;&gt;display(&apos;footer.tpl&apos;);?&gt;</description>
      <dc:subject>Chapter 16 Code</dc:subject>
      <dc:date>2006-09-27T18:25:00-06:00</dc:date>
    </item>

    <item>
      <title>Example 16&#45;15 post_form.tpl</title>
      <link>http://www.krautgrrl.com/learningphp/index.php/site/example_16_15_post_formtpl/</link>
      <guid>http://www.krautgrrl.com/learningphp/index.php/site/example_16_15_post_formtpl/#When:18:19:00Z</guid>
      <description>&lt;form&#160;action=&quot;modify_post.php&quot;&#160;method=&quot;POST&quot;&gt;&lt;label&gt;Title:&#160;&#160;&lt;input&#160;type=&quot;text&quot;&#160;name=&quot;title&quot;&#160;value=&quot;&#123;$posts&#91;mysec&#93;.title&#125;&quot;&gt;&lt;/label&gt;&lt;br&#160;&#160;/&gt;&lt;br&#160;&#160;/&gt;&lt;label&gt;Body:&#160;&#160;&lt;textarea&#160;name=&quot;body&quot;&#160;cols=&quot;40&quot;&#160;rows=&quot;4&quot;&gt;&#123;$posts&#91;mysec&#93;.body&#125;&lt;/textarea&gt;&lt;/label&gt;&lt;input&#160;&#160;type=&quot;hidden&quot;&#160;name=&quot;action&quot;&#160;&#160;value=&quot;&#123;$action&#125;&quot;&gt;&lt;input&#160;&#160;type=&quot;hidden&quot;&#160;name=&quot;post_id&quot;&#160;&#160;value=&quot;&#123;$posts&#91;mysec&#93;.post_id&#125;&quot;&gt;&lt;br&gt;&lt;label&gt;&#160;Category:&#123;html_options&#160;&#160;name=&quot;category_id&quot;&#160;options=$categories&#160;selected=$posts&#91;mysec&#93;.category_id&#125;&lt;/label&gt;&lt;br&#160;&#160;/&gt;&lt;input&#160;&#160;type=&quot;submit&quot;&#160;name=&quot;submit&quot;&#160;value=&quot;Post&quot;&#160;&#160;/&gt;&lt;/form&gt;&#123;/section&#125;</description>
      <dc:subject>Chapter 16 Code</dc:subject>
      <dc:date>2006-09-27T18:19:00-06:00</dc:date>
    </item>

    <item>
      <title>Example 16&#45;14 modify_posts.php</title>
      <link>http://www.krautgrrl.com/learningphp/index.php/site/example_16_14_modify_postsphp/</link>
      <guid>http://www.krautgrrl.com/learningphp/index.php/site/example_16_14_modify_postsphp/#When:17:55:00Z</guid>
      <description>&lt;?php&#160;&#160;&#160;&#160;include(&apos;db_login.php&apos;);&#160;&#160;&#160;&#160;require_once(&#160;&#160;&apos;DB.php&apos;&#160;&#160;);&#160;&#160;&#160;&#160;require_once(&#160;&#160;&apos;config.php&apos;&#160;&#160;);&#160;&#160;&#160;&#160;//check&#160;&#160;for&#160;&#160;valid&#160;&#160;login&#160;&#160;&#160;&#160;session_start();&#160;&#160;&#160;&#160;//display&#160;&#160;the&#160;&#160;header&#160;&#160;&#160;&#160;$smarty&#45;&gt;assign(&apos;blog_title&apos;,$blog_title);&#160;&#160;&#160;&#160;$smarty&#45;&gt;display(&apos;header.tpl&apos;);&#160;&#160;&#160;&#160;if&#160;&#160;&#160;&#160;(!isset($_SESSION&#91;&apos;username&apos;&#93;))&#160;&#160;&#123;&#160;&#160;&#160;&#160;echo&#160;&#160;(&quot;Please&#160;&#160;&lt;a&#160;&#160;href=&apos;login.php&apos;&gt;login&lt;/a&gt;.&quot;);&#160;&#160;&#160;&#160;exit();&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;//grab&#160;&#160;submission&#160;&#160;variables&#160;&#160;&#160;&#160;$post_id=$_POST&#91;post_id&#93;;&#160;&#160;&#160;&#160;$title=htmlentities($_POST&#91;&apos;title&apos;&#93;);&#160;&#160;&#160;&#160;$body=htmlentities($_POST&#91;&apos;body&apos;&#93;);&#160;&#160;&#160;&#160;$action=htmlentities($_POST&#91;&apos;action&apos;&#93;);&#160;&#160;&#160;&#160;$category_id=htmlentities($_POST&#91;&apos;category_id&apos;&#93;);&#160;&#160;&#160;&#160;$user_id=$_SESSION&#91;&quot;user_id&quot;&#93;;&#160;&#160;&#160;&#160;//conected&#160;to&#160;database&#160;&#160;&#160;&#160;$connection&#160;&#160;=&#160;&#160;DB::connect(&#160;&#160;&quot;mysql://$db_username:$db_password@$db_host/$db_database&quot;&#160;&#160;);&#160;&#160;&#160;&#160;if&#160;&#160;(!$connection)&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;die&#160;&#160;(&quot;Could&#160;not&#160;connect&#160;to&#160;the&#160;database:&#160;&lt;br&gt;&quot;.&#160;DB::errorMessage());&#160;&#160;&#160;&#160;&#125;;&#160;&#160;&#160;&#160;if&#160;&#160;($_GET&#91;&apos;action&apos;&#93;==&quot;delete&quot;&#160;&#160;and&#160;&#160;!$stop)&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;$post_id=$_GET&#91;post_id&#93;;&#160;&#160;&#160;&#160;$query&#160;&#160;=&#160;&#160;&quot;delete&#160;from&#160;posts&#160;where&#160;post_id=&apos;&quot;.$post_id.&quot;&apos;&#160;anduser_id=&apos;&quot;.$user_id.&quot;&apos;&quot;;&#160;&#160;&#160;&#160;$result&#160;&#160;=&#160;&#160;$connection&#45;&gt;query($query);&#160;&#160;&#160;&#160;if&#160;(DB::isError($result))&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;die&#160;(&quot;Could&#160;not&#160;&#160;query&#160;the&#160;database:&#160;&lt;br&gt;&quot;.&#160;&#160;$query.&#160;&#160;&quot;&#160;&#160;&quot;.DB::errorMessage($result));&#160;&#160;&#160;&#160;&#125;;&#160;&#160;&#160;&#160;echo&#160;&#160;(&quot;Deleted&#160;&#160;successfully.&lt;br&gt;&quot;);&#160;&#160;&#160;&#160;$stop=&quot;TRUE&quot;;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;//we&apos;re&#160;editing&#160;an&#160;entry,&#160;explicitly&#160;grab&#160;the&#160;id&#160;from&#160;the&#160;URL&#160;&#160;&#160;&#160;if&#160;&#160;($_GET&#91;post_id&#93;&#160;&#160;AND&#160;&#160;!$stop)&#160;&#160;&#123;&#160;&#160;&#160;&#160;$query&#160;&#160;=&#160;&#160;&quot;SELECT&#160;*&#160;FROM&#160;users&#160;NATURAL&#160;JOIN&#160;posts&#160;NATURAL&#160;JOIN&#160;categorieswhere&#160;&#160;post_id&#160;&#160;=&#160;&#160;$_GET&#91;post_id&#93;&quot;;&#160;&#160;&#160;&#160;$result&#160;&#160;=&#160;&#160;$connection&#45;&gt;query($query);&#160;&#160;&#160;&#160;if&#160;&#160;(DB::isError($result))&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;die&#160;&#160;(&quot;Could&#160;not&#160;query&#160;the&#160;database:&#160;&lt;br&gt;&quot;.&#160;$query.&#160;&#160;&quot;&#160;&#160;&quot;.DB::errorMessage($result));&#160;&#160;&#160;&#160;&#125;;&#160;&#160;&#160;&#160;while&#160;&#160;($result_row&#160;&#160;=&#160;&#160;$result&#45;&gt;fetchRow(DB_FETCHMODE_ASSOC))&#160;&#160;&#123;&#160;&#160;&#160;&#160;$posts&#91;&#93;=$result_row;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;$smarty&#45;&gt;assign(&apos;action&apos;,&apos;edit&apos;);&#160;&#160;&#160;&#160;$smarty&#45;&gt;assign(&apos;posts&apos;,$posts);&#160;&#160;&#160;&#160;//get&#160;&#160;those&#160;&#160;categories&#160;&#160;&#160;&#160;$query&#160;&#160;=&#160;&#160;&quot;SELECT&#160;&#160;category_id,&#160;category&#160;FROM&#160;categories&quot;;&#160;&#160;&#160;&#160;$smarty&#45;&gt;assign(&apos;categories&apos;,$connection&#45;&gt;getAssoc($query));&#160;&#160;&#160;&#160;$smarty&#45;&gt;display(&apos;post_form.tpl&apos;);&#160;&#160;&#160;&#160;$stop=&quot;TRUE&quot;;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;//The&#160;form&#160;was&#160;submitted,&#160;was&#160;it&#160;an&#160;add&#160;or&#160;an&#160;edit?&#160;&#160;&#160;&#160;if&#160;&#160;($_POST&#91;&apos;submit&apos;&#93;&#160;&#160;AND&#160;&#160;!$stop)&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;//validate&#160;fields&#160;&#160;&#160;&#160;if&#160;&#160;($title&#160;&#160;==&#160;&#160;&quot;&quot;)&#123;&#160;&#160;&#160;&#160;echo&#160;&#160;(&quot;Title&#160;must&#160;not&#160;be&#160;null.&lt;br&gt;&quot;);&#160;&#160;&#160;&#160;$found_error=TRUE;&#160;&#160;&#160;&#160;$stop=&quot;TRUE&quot;;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;if&#160;&#160;($body&#160;&#160;==&#160;&#160;&quot;&quot;)&#123;&#160;&#160;&#160;&#160;echo&#160;&#160;(&quot;Body&#160;must&#160;not&#160;be&#160;null.&lt;br&gt;&quot;);&#160;&#160;&#160;&#160;$found_error=TRUE;&#160;&#160;&#160;&#160;$stop=&quot;TRUE&quot;;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;//validated&#160;OK&#160;lets&#160;hit&#160;the&#160;databae&#160;&#160;&#160;&#160;if&#160;&#160;(&#160;&#160;$_POST&#91;&apos;action&apos;&#93;==&quot;add&quot;&#160;AND&#160;!$stop)&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;$query&#160;=&#160;&quot;insert&#160;into&#160;posts&#160;values&#160;&#160;(NULL,&quot;.&quot;&apos;&quot;.$category_id.&quot;&apos;,&apos;&quot;.$user_id.&quot;&apos;,&apos;&quot;.$title.&quot;&apos;,&apos;&quot;.$body.&quot;&apos;,&#160;&#160;NULL)&quot;;&#160;&#160;&#160;&#160;$result&#160;&#160;=&#160;&#160;$connection&#45;&gt;query($query);&#160;&#160;&#160;&#160;if&#160;&#160;(DB::isError($result))&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;die&#160;&#160;(&quot;Could&#160;not&#160;query&#160;the&#160;database:&#160;&lt;br&gt;&quot;.&#160;$query.&#160;&#160;&quot;&#160;&#160;&quot;.DB::errorMessage($result));&#160;&#160;&#160;&#160;&#125;;&#160;&#160;&#160;&#160;echo&#160;&#160;(&quot;Posted&#160;successfully.&lt;br&gt;&quot;);&#160;&#160;&#160;&#160;$stop=&quot;TRUE&quot;;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;if&#160;&#160;($_POST&#91;&apos;action&apos;&#93;==&quot;edit&quot;&#160;and&#160;!$stop)&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;//do&#160;nothing&#160;&#160;&#160;&#160;$query&#160;&#160;=&#160;&#160;&quot;update&#160;posts&#160;set&#160;category_id&#160;&#160;=&apos;&quot;.$category_id.&quot;&apos;,title&#160;&#160;=&apos;&quot;.$title.&quot;&apos;,body=&apos;&quot;.$body.&quot;&apos;&#160;where&#160;post_id=&apos;&quot;.$post_id.&quot;&apos;and&#160;&#160;user_id=&apos;&quot;.$user_id.&quot;&apos;&quot;;&#160;&#160;&#160;&#160;//echo&#160;$query;&#160;&#160;&#160;&#160;$result&#160;=&#160;$connection&#45;&gt;query($query);&#160;&#160;&#160;&#160;if&#160;&#160;(DB::isError($result))&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;die&#160;&#160;(&quot;Could&#160;not&#160;query&#160;the&#160;database:&#160;&lt;br&gt;&quot;.&#160;$query.&#160;&#160;&quot;&#160;&#160;&quot;.DB::errorMessage($result));&#160;&#160;&#160;&#160;&#125;;&#160;&#160;&#160;&#160;echo&#160;(&quot;Updated&#160;successfully.&lt;br&gt;&quot;);&#160;&#160;&#160;&#160;$stop=&quot;TRUE&quot;;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;if&#160;&#160;(!$stop)&#160;&#160;&#160;&#160;&#123;&#160;&#160;&#160;&#160;//display&#160;blank&#160;form&#160;&#160;&#160;&#160;//create&#160;an&#160;empty&#160;entry&#160;&#160;&#160;&#160;$result_row=array(&apos;title&apos;=&gt;NULL,&apos;body&apos;=&gt;NULL);&#160;&#160;&#160;&#160;$posts&#91;&#93;=$result_row;&#160;&#160;&#160;&#160;//get&#160;the&#160;categories&#160;&#160;&#160;&#160;$query&#160;=&#160;&quot;SELECT&#160;category_id,&#160;category&#160;FROM&#160;categories&quot;;&#160;&#160;&#160;&#160;$smarty&#45;&gt;assign(&apos;categories&apos;,$connection&#45;&gt;getAssoc($query));&#160;&#160;&#160;&#160;$smarty&#45;&gt;assign(&apos;posts&apos;,$posts);&#160;&#160;&#160;&#160;$smarty&#45;&gt;assign(&apos;action&apos;,&apos;add&apos;);&#160;&#160;&#160;&#160;$smarty&#45;&gt;display(&apos;post_form.tpl&apos;);&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;if&#160;&#160;($found_error)&#160;&#160;&#123;&#160;&#160;&#160;&#160;//assign&#160;old&#160;vals&#160;&#160;&#160;&#160;//redisplay&#160;form&#160;&#160;&#160;&#160;$result_row=array(&apos;title&apos;=&gt;&quot;$title&quot;,&apos;body&apos;=&gt;&quot;$body&quot;,&apos;post_id&apos;=&gt;&quot;$post_id&quot;);&#160;&#160;&#160;&#160;$posts&#91;&#93;=$result_row;&#160;&#160;&#160;&#160;$smarty&#45;&gt;assign(&apos;action&apos;,$action);&#160;&#160;&#160;&#160;$smarty&#45;&gt;assign(&apos;posts&apos;,$posts);&#160;&#160;&#160;&#160;$smarty&#45;&gt;display(&apos;post_form.tpl&apos;);&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;//display&#160;the&#160;footer&#160;&#160;&#160;&#160;$smarty&#45;&gt;display(&apos;footer.tpl&apos;);?&gt;</description>
      <dc:subject>Chapter 16 Code</dc:subject>
      <dc:date>2006-09-27T17:55:00-06:00</dc:date>
    </item>

    <item>
      <title>Example 16&#45;13 view_post.tpl</title>
      <link>http://www.krautgrrl.com/learningphp/index.php/site/example_16_13_view_posttpl/</link>
      <guid>http://www.krautgrrl.com/learningphp/index.php/site/example_16_13_view_posttpl/#When:17:51:00Z</guid>
      <description>&#123;section&#160;&#160;name=mysec&#160;&#160;loop=$posts&#125;&lt;h2&gt;&#123;$posts&#91;mysec&#93;.title&#125;&lt;/h2&gt;&#123;$posts&#91;mysec&#93;.body&#125;&lt;br&#160;&#160;/&gt;Posted&#160;&#160;by&#160;&#160;&lt;b&gt;&#123;$posts&#91;mysec&#93;.first_name&#125;&#160;&#160;&#123;$posts&#91;mysec&#93;.last_name&#125;&lt;/b&gt;from&#160;&#160;the&#160;&#160;&lt;b&gt;&#123;$posts&#91;mysec&#93;.category&#125;&lt;/b&gt;&#160;&#160;category&#160;&#160;at&lt;b&gt;&#123;$posts&#91;mysec&#93;.posted&#125;&lt;/b&gt;.&lt;br&#160;&#160;/&gt;&#123;if&#160;&#160;$posts&#91;mysec&#93;.user_id&#160;&#160;==&#160;&#160;$owner_id&#125;&lt;a&#160;&#160;href=&quot;modify_post.php?post_id=&#123;$posts&#91;mysec&#93;.post_id&#125;&amp;action=edit&quot;&gt;Edit&lt;/a&gt;&#160;&#160;||&lt;a&#160;&#160;href=&quot;modify_post.php?post_id=&#123;$posts&#91;mysec&#93;.post_id&#125;&amp;action=delete&quot;&gt;Delete&lt;/a&gt;&#160;&#160;||&lt;a&#160;&#160;href=&quot;modify_comment.php?post_id=&#123;$posts&#91;mysec&#93;.post_id&#125;&amp;action=add&quot;&gt;Add&#160;&#160;a&#160;&#160;comment&lt;/a&gt;&lt;br&#160;&#160;/&gt;&#123;/if&#125;&#123;/section&#125;&#123;if&#160;&#160;$comment_count&#160;&#160;!=&#160;&#160;&quot;0&quot;&#125;&lt;h3&gt;Comments&lt;/h3&gt;&#123;section&#160;&#160;name=mysec2&#160;&#160;loop=$comments&#125;&lt;hr&#160;&#160;/&gt;&lt;b&gt;&#123;$comments&#91;mysec2&#93;.title&#125;&lt;/b&gt;&lt;br&#160;&#160;/&gt;&#123;$comments&#91;mysec2&#93;.body&#125;&lt;br&#160;&#160;/&gt;Posted&#160;&#160;by&#160;&#160;&lt;b&gt;&#123;$comments&#91;mysec2&#93;.first_name&#125;&#160;&#160;&#123;$comments&#91;mysec2&#93;.last_name&#125;&lt;/b&gt;at&#160;&#160;&lt;b&gt;&#123;$comments&#91;mysec2&#93;.posted&#125;&lt;/b&gt;.&lt;br&#160;&#160;/&gt;&#123;if&#160;&#160;$comments&#91;mysec2&#93;.user_id&#160;&#160;==&#160;&#160;$owner_id&#125;&lt;a&#160;&#160;href=&quot;modify_comment.php?comment_id=&#123;$comments&#91;mysec2&#93;.comment_id&#125;&amp;action=edit&quot;&gt;Edit&lt;/a&gt;&#160;&#160;||&lt;a&#160;&#160;href=&quot;modify_comment.php?comment_id=&#123;$comments&#91;mysec2&#93;.comment_id&#125;&amp;action=delete&quot;&gt;Delete&lt;/a&gt;&lt;br&#160;&#160;/&gt;&#123;/if&#125;&#123;/section&#125;&#123;/if&#125;</description>
      <dc:subject>Chapter 16 Code</dc:subject>
      <dc:date>2006-09-27T17:51:00-06:00</dc:date>
    </item>

    <item>
      <title>Example 16&#45;12 The view_post.php script displays and a summary of its comments</title>
      <link>http://www.krautgrrl.com/learningphp/index.php/site/example_16_12_the_view_postphp_script_displays_and_a_summary_of_its_comment/</link>
      <guid>http://www.krautgrrl.com/learningphp/index.php/site/example_16_12_the_view_postphp_script_displays_and_a_summary_of_its_comment/#When:17:46:00Z</guid>
      <description>&lt;?php&#160;session_start();require_once(&apos;config.php&apos;);require_once(&apos;db_login.php&apos;);require_once(&quot;DB.php&quot;);//&#160;&#160;Display&#160;&#160;the&#160;&#160;header$smarty&#45;&gt;assign(&apos;blog_title&apos;,$blog_title);$smarty&#45;&gt;display(&apos;header.tpl&apos;);//&#160;&#160;Check&#160;&#160;for&#160;&#160;valid&#160;&#160;loginif&#160;&#160;(!isset($_SESSION&#91;&quot;username&quot;&#93;))&#160;&#160;&#123;echo&#160;&#160;&apos;Please&#160;&#160;&lt;a&#160;&#160;href=&quot;login.php&quot;&gt;login&lt;/a&gt;.&apos;;exit;&#125;//&#160;&#160;Connect&#160;&#160;to&#160;&#160;the&#160;&#160;database$connection&#160;&#160;=&#160;&#160;DB::connect(&quot;mysql://$db_username:$db_password@$db_host/$db_database&quot;);if&#160;&#160;(DB::isError($connection))&#123;die&#160;&#160;(&quot;Could&#160;not&#160;connect&#160;to&#160;the&#160;database:&#160;&#160;&lt;br&#160;&#160;/&gt;&quot;.&#160;&#160;DB::errorMessage($connection));&#125;$post_id&#160;&#160;=&#160;&#160;$_GET&#91;&quot;post_id&quot;&#93;;$query&#160;&#160;=&#160;&#160;&quot;SELECT&#160;*&#160;FROM&#160;`users`&#160;NATURAL&#160;JOIN&#160;`posts`&#160;NATURAL&#160;JOIN&#160;`categories`WHERE&#160;&#160;`post_id`=$post_id&quot;;$result&#160;&#160;=&#160;&#160;$connection&#45;&gt;query($query);if&#160;&#160;(DB::isError($result))&#123;die(&quot;Could&#160;not&#160;query&#160;the&#160;database:&#160;&lt;br&#160;&#160;/&gt;&quot;.$query.&quot;&#160;&#160;&quot;.DB::errorMessage($result));&#125;while&#160;&#160;($result_row&#160;&#160;=&#160;&#160;$result&#45;&gt;fetchRow(DB_FETCHMODE_ASSOC))&#160;&#160;&#123;$test&#91;&#93;=$result_row;&#125;$smarty&#45;&gt;assign(&apos;posts&apos;,$test);$smarty&#45;&gt;assign(&apos;owner_id&apos;,$_SESSION&#91;&quot;user_id&quot;&#93;);$query&#160;&#160;=&#160;&#160;&quot;SELECT&#160;*&#160;FROM&#160;`users`&#160;NATURAL&#160;JOIN&#160;`comments`&#160;WHERE&#160;`post_id`=$post_id&quot;;$result&#160;&#160;=&#160;&#160;$connection&#45;&gt;query($query);if&#160;&#160;(DB::isError($result))&#123;die(&quot;Could&#160;not&#160;query&#160;the&#160;database:&#160;&#160;&lt;br&#160;&#160;/&gt;&quot;.$query.&quot;&#160;&#160;&quot;.DB::errorMessage($result));&#125;$comment_count&#160;&#160;=&#160;&#160;$result&#45;&gt;numRows();while&#160;&#160;($result_row&#160;&#160;=&#160;&#160;$result&#45;&gt;fetchRow(DB_FETCHMODE_ASSOC))&#160;&#160;&#123;$comments&#91;&#93;&#160;&#160;=&#160;&#160;$result_row;&#125;$smarty&#45;&gt;assign(&apos;posts&apos;,$test);$smarty&#45;&gt;assign(&apos;comments&apos;,$comments);$smarty&#45;&gt;assign(&apos;comment_count&apos;,$comment_count);$smarty&#45;&gt;display(&apos;view_post.tpl&apos;);$connection&#45;&gt;disconnect();//&#160;&#160;Display&#160;the&#160;footer$smarty&#45;&gt;display(&apos;footer.tpl&apos;);?&gt;</description>
      <dc:subject>Chapter 16 Code</dc:subject>
      <dc:date>2006-09-27T17:46:00-06:00</dc:date>
    </item>

    <item>
      <title>Example 16&#45;11 The posts.tpl template file defines how the postings appear on the page</title>
      <link>http://www.krautgrrl.com/learningphp/index.php/site/example_16_11_the_poststpl_template_file_defines_how_the_postings_appear_on/</link>
      <guid>http://www.krautgrrl.com/learningphp/index.php/site/example_16_11_the_poststpl_template_file_defines_how_the_postings_appear_on/#When:17:45:00Z</guid>
      <description>&#123;section&#160;&#160;name=mysec&#160;&#160;loop=$posts&#125;&lt;a&#160;&#160;href=&quot;view_post.php?post_id=&#123;$posts&#91;mysec&#93;.post_id&#125;&quot;&gt;&#123;$posts&#91;mysec&#93;.title&#125;&lt;/a&gt;by&#160;&#160;&lt;b&gt;&#123;$posts&#91;mysec&#93;.first_name&#125;&#160;&#160;&#123;$posts&#91;mysec&#93;.last_name&#125;&lt;/b&gt;from&#160;&#160;the&#160;&#160;&lt;b&gt;&#123;$posts&#91;mysec&#93;.category&#125;&lt;/b&gt;&#160;&#160;category&#160;&#160;at&#160;&#160;&lt;b&gt;&#123;$posts&#91;mysec&#93;.posted&#125;&lt;/b&gt;.&lt;br&#160;&#160;/&gt;&#123;/section&#125;&lt;br&#160;&#160;/&gt;Click&#160;to&#160;&lt;a&#160;&#160;href=&quot;modify_post.php?action=add&quot;&gt;add&lt;/a&gt;&#160;a&#160;posting.&lt;br&#160;&#160;/&gt;</description>
      <dc:subject>Chapter 16 Code</dc:subject>
      <dc:date>2006-09-27T17:45:00-06:00</dc:date>
    </item>

    
    </channel>
</rss>