<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-7702816563349321195</atom:id><lastBuildDate>Mon, 09 May 2022 07:24:19 +0000</lastBuildDate><category>ruby on rails</category><category>Ruby</category><category>Rails</category><category>javascript</category><category>PHP</category><category>Collection</category><category>css</category><category>jQuery</category><category>Rails 3</category><category>Interview Questions</category><category>Question and Answers</category><category>Tutorials</category><category>Web Development</category><category>ubuntu</category><category>.htaccess</category><category>APN</category><category>Cocoon</category><category>Collection : Javascript</category><category>Collection : PHP</category><category>Data Sequencing</category><category>Rails Best Practices</category><category>SMTP</category><category>SQL</category><category>Windows</category><category>WordPress</category><category>html</category><category>vista</category><category>API</category><category>Action Mailer</category><category>Android</category><category>Authentication</category><category>BIRT</category><category>Broadband</category><category>CSV</category><category>CakePHP</category><category>Code</category><category>Comments</category><category>Database</category><category>Database Structure</category><category>Defragment</category><category>Devise</category><category>ECJ</category><category>Eclipse</category><category>Editor</category><category>Facebook</category><category>FasterCSV</category><category>Heroku</category><category>Hosting</category><category>Immutable</category><category>Import</category><category>Info</category><category>JDBC</category><category>Liferay</category><category>MTNL</category><category>Mixin</category><category>Mutable</category><category>MySQL</category><category>Nick Kallen</category><category>Node.js</category><category>Notifications</category><category>Nuts and Bolts</category><category>Omniauth</category><category>One Click Installer</category><category>Phonegap</category><category>Portlets</category><category>Postgres</category><category>REST</category><category>Rake</category><category>Refactoring</category><category>Regex</category><category>Regular Expressions</category><category>Robert Sosinski</category><category>Rubular</category><category>Sequence data</category><category>Stored Procedures</category><category>Strings</category><category>Surrender Router</category><category>Symbols</category><category>Terminal</category><category>Timezone</category><category>Upload Limit</category><category>abd</category><category>flash</category><category>has_finder</category><category>iOS 5.0</category><category>link_to_remove_association</category><category>mod_rewrite services</category><category>named_scope</category><category>phpmyadmin</category><category>scope</category><title>Supriya&#39;s Blog</title><description></description><link>http://blog.supriyasurve.com/</link><managingEditor>noreply@blogger.com (Supriya Surve)</managingEditor><generator>Blogger</generator><openSearch:totalResults>86</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-3003561662477955096</guid><pubDate>Sat, 14 Nov 2015 09:45:00 +0000</pubDate><atom:updated>2017-02-02T01:47:09.590-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Comments</category><category domain="http://www.blogger.com/atom/ns#">PHP</category><category domain="http://www.blogger.com/atom/ns#">WordPress</category><title>PHP : Wordpress : Comments template not rendering</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Somehow my new custom post type was not able to get the comments section. After debugging and looking for option found solution for this issue at &lt;a href=&quot;http://wpquestions.com/question/show/id/2678&quot;&gt;WP Questions&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I just updated the wp_posts with below mentioned query:&lt;br /&gt;&lt;br /&gt; &lt;pre&gt;&lt;code&gt;UPDATE wp_posts SET comment_status = &#39;open&#39; WHERE post_type = &#39;myposttype&#39;;&lt;/code&gt;&lt;/pre&gt; &amp;nbsp;And&amp;nbsp; it worked.&lt;/div&gt;</description><link>http://blog.supriyasurve.com/2015/11/php-wordpress-comments-template-not.html</link><author>noreply@blogger.com (Supriya Surve)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-553457289734017989</guid><pubDate>Wed, 15 Jan 2014 06:08:00 +0000</pubDate><atom:updated>2014-01-14T22:09:04.616-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.htaccess</category><category domain="http://www.blogger.com/atom/ns#">PHP</category><category domain="http://www.blogger.com/atom/ns#">Upload Limit</category><category domain="http://www.blogger.com/atom/ns#">WordPress</category><title>PHP : Wordpress : Increase media file size</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Working on WordPress was a great change for me. But for media upload I wanted to increase the upload size for file selected. Checked several plugins but was not working properly.  One of the comment by &lt;a href=&quot;http://www.bestwpthemez.com/&quot;&gt;Shane G&lt;/a&gt; on &lt;a href=&quot;http://wordpress.org/support/topic/increase-media-library-upload-file-size-limit#post-1406259&quot;&gt;WordPress support site&lt;/a&gt; I found useful. &lt;br /&gt;&lt;br /&gt;Just add below code in .htaccess file.&lt;br /&gt;&lt;pre&gt;php_value upload_max_filesize 20M&lt;br /&gt;php_value post_max_size 20M&lt;br /&gt;php_value max_execution_time 200&lt;br /&gt;php_value max_input_time 200&lt;br /&gt;&lt;/pre&gt;And it works like a charm. &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2014/01/php-wordpress-increase-media-file-size.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-8759873855601815939</guid><pubDate>Thu, 21 Nov 2013 06:00:00 +0000</pubDate><atom:updated>2013-11-20T22:00:47.710-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">BIRT</category><category domain="http://www.blogger.com/atom/ns#">Eclipse</category><category domain="http://www.blogger.com/atom/ns#">JDBC</category><category domain="http://www.blogger.com/atom/ns#">MySQL</category><title>Eclipse : Birt : Build JDBC:MYSQL connection</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;For connecting the reports to mysql database was fun. &lt;br /&gt;For that I followed the &lt;a href=&quot;http://www.slideshare.net/vazi/birt-installation-and-configuration&quot;&gt;birt-installation-and-configuration&lt;/a&gt; which was easy to understand.&lt;br /&gt;&lt;br /&gt;Now as per the tutorial for adding external file &lt;br /&gt;&lt;i&gt;Select Project &amp;gt; right click &amp;gt; properties &amp;gt; Classpath &amp;gt; Add external JARs&lt;/i&gt; and go to path &lt;i&gt;/usr/share/java&lt;/i&gt; folder(For Ubuntu and for windows please check the link above).&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-EgrhFMM2YAc/Ule1EBt2HLI/AAAAAAAACbo/_XRb6QL5dqA/s1600/external_jar.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-EgrhFMM2YAc/Ule1EBt2HLI/AAAAAAAACbo/_XRb6QL5dqA/s1600/external_jar.png&quot; height=&quot;414&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Once this is done we create the new data source with mysql connection. &lt;br /&gt;&lt;i&gt;Navigator(in sidebar) &amp;gt; Data Source &amp;gt; Right Click &amp;gt; New Data Source&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt; &lt;a href=&quot;http://4.bp.blogspot.com/-DSCrpbxc2ak/Ule1nO_0rCI/AAAAAAAACbw/ZB8RCrr4O6Q/s1600/create_db.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-DSCrpbxc2ak/Ule1nO_0rCI/AAAAAAAACbw/ZB8RCrr4O6Q/s1600/create_db.png&quot; height=&quot;480&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Once data source name is given click Next and&lt;br /&gt;Select &lt;code&gt;com.mysql.jdbc.Driver(v5.1)&lt;/code&gt; &lt;br /&gt;Database URL add : &lt;code&gt;jdbc:mysql://your_host_name/your_db_name&lt;/code&gt;&lt;br /&gt;User Name and Password of the connection&lt;br /&gt;Click on Test Connection&lt;br /&gt;It should display dialog box as shown in the image below indicating that the connection is successfully build.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-3YQ3SKzljPw/Ule3lCarw2I/AAAAAAAACcE/1ZmqKnUDHa0/s1600/test_connection.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-3YQ3SKzljPw/Ule3lCarw2I/AAAAAAAACcE/1ZmqKnUDHa0/s1600/test_connection.png&quot; height=&quot;480&quot; width=&quot;640&quot; /&gt;&lt;/a&gt; &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/11/eclipse-birt-build-jdbcmysql-connection.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-EgrhFMM2YAc/Ule1EBt2HLI/AAAAAAAACbo/_XRb6QL5dqA/s72-c/external_jar.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-1244231948559505444</guid><pubDate>Tue, 08 Oct 2013 06:48:00 +0000</pubDate><atom:updated>2013-10-08T04:22:47.227-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ECJ</category><category domain="http://www.blogger.com/atom/ns#">Liferay</category><category domain="http://www.blogger.com/atom/ns#">Portlets</category><title>Liferay : Portlets : Task cannot continue because ECJ is not installed</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;While going through &lt;a href=&quot;http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/creating-a-portlet&quot;&gt;Liferay Portal 6.0 - Development Guide : Creating a Portlet&lt;/a&gt; I got error on running ant task. &lt;br /&gt;&lt;pre&gt;Task cannot continue because ECJ is not installed.&lt;br /&gt;ECJ was automatically installed. Please rerun your task.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-T_OPdcnaqAw/UlOo0YpRW0I/AAAAAAAACac/RNENSFrc8Hk/s1600/task_not_found.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-T_OPdcnaqAw/UlOo0YpRW0I/AAAAAAAACac/RNENSFrc8Hk/s1600/task_not_found.png&quot; height=&quot;162&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;After searching for solution got &lt;a href=&quot;http://www.liferaysolution.com/2012/09/solve-ecj-error-in-liferay-ide.html#.UlOk1X3gyJO&quot;&gt;Solve ECJ error in liferay IDE &lt;/a&gt; on  &lt;a href=&quot;http://www.liferaysolution.com/&quot;&gt;Liferay Solutions&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Just followed the steps suggested. &lt;br /&gt;&lt;b&gt;Window -&amp;gt; Preferences -&amp;gt; Ant -&amp;gt; Runtime&amp;nbsp;&lt;/b&gt; &lt;br /&gt;Then &lt;b&gt;Ant Home Button&lt;/b&gt; and&amp;nbsp; &lt;b&gt;Add external jar&lt;/b&gt; called &lt;b&gt;ecj.jar&lt;/b&gt; which was in &lt;b&gt;plugin-sdk-folder-path/lib&lt;/b&gt; &lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-KNOuf60UEZc/UlPq7sNfmaI/AAAAAAAACa8/LzV4Ku-Bzk0/s1600/ecj_lib_folder.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-KNOuf60UEZc/UlPq7sNfmaI/AAAAAAAACa8/LzV4Ku-Bzk0/s1600/ecj_lib_folder.png&quot; height=&quot;428&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-pfHGvDTHQWc/UlOpLO5joYI/AAAAAAAACak/78eYlkI52Uc/s1600/ecj_lib_folder.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;And After running the Ant Task portlet deployed successfully.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-Y5glz0pU1k4/UlOpkSXRY4I/AAAAAAAACas/k9fOUGBmD3c/s1600/ecj_found_portlet.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-Y5glz0pU1k4/UlOpkSXRY4I/AAAAAAAACas/k9fOUGBmD3c/s1600/ecj_found_portlet.png&quot; height=&quot;279&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/10/liferay-portlets-task-cannot-continue.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-T_OPdcnaqAw/UlOo0YpRW0I/AAAAAAAACac/RNENSFrc8Hk/s72-c/task_not_found.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-1621686881502276557</guid><pubDate>Tue, 10 Sep 2013 05:17:00 +0000</pubDate><atom:updated>2013-09-09T22:17:05.169-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL</category><category domain="http://www.blogger.com/atom/ns#">Stored Procedures</category><title>SQL : Stored Procedures : Next working date</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Working on stored procedures is fun. For 1 functionality, wanted to get next working date which will exclude saturday sundays and dates from holiday list table.&lt;br /&gt;&lt;br /&gt;I got really nice solution on &lt;a href=&quot;http://amrutbudihal.blogspot.in/2011/10/mysql-stored-procedure-for-computing.html&quot;&gt;mysql-stored-procedure-for-computing&lt;/a&gt;. But only draw back was Recursive limit. But tried the solution added in comments.&lt;br /&gt;&lt;br /&gt;Checked and it worked fine. Only change done in this solution that if no date provided for function it should take current date. And parameter numDays removed.&lt;br /&gt;&lt;br /&gt;So if current date is 2013-09-04. 2013-09-05 and 2013-09-06 in holiday list table.  2013-09-07 is Saturday and 2013-09-08 Sunday.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-WTcLL6DFPbg/UibW04aZScI/AAAAAAAACGs/mHlzJ-m8kc0/s1600/Screenshot+from+2013-09-04+12:06:23.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-WTcLL6DFPbg/UibW04aZScI/AAAAAAAACGs/mHlzJ-m8kc0/s1600/Screenshot+from+2013-09-04+12:06:23.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The output should be&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-OUrRVEy3d_Y/UibWlwn2DJI/AAAAAAAACGk/GkchLtEs3jw/s1600/Screenshot+from+2013-09-04+12:06:07.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-OUrRVEy3d_Y/UibWlwn2DJI/AAAAAAAACGk/GkchLtEs3jw/s1600/Screenshot+from+2013-09-04+12:06:07.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And instead of both functions changed one to stored procedure as below.&lt;br /&gt;&lt;b&gt;Stored Procedure : sp_get_next_working_date&lt;/b&gt;&lt;br /&gt;&lt;pre&gt;/**&lt;br /&gt;Stored Procedure : sp_get_next_working_date&lt;br /&gt;Parameter : p_date as date&lt;br /&gt;Description : Returns next working date excluding Saturday/ Sunday OR Date in holiday list table.&lt;br /&gt;Dependency : Function fn_check_date_if_in_holiday_list &lt;br /&gt;**/&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;  DECLARE next_working_date DATE;&lt;br /&gt;  SET next_working_date = p_date;&lt;br /&gt;&lt;br /&gt;  IF p_date = 0 THEN &lt;br /&gt;    SET next_working_date = DATE(NOW()); &lt;br /&gt;  END IF;&lt;br /&gt;  SET next_working_date = DATE_ADD(next_working_date, INTERVAL 1 DAY);&lt;br /&gt;&lt;br /&gt;  WHILE fn_check_date_if_in_holiday_list(next_working_date) DO &lt;br /&gt;    SET next_working_date = DATE_ADD(next_working_date, INTERVAL 1 DAY);&lt;br /&gt;  END WHILE;&lt;br /&gt;&lt;br /&gt;  SELECT next_working_date;&lt;br /&gt;END&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;Function : fn_check_date_if_in_holiday_list&lt;/b&gt;&lt;br /&gt;&lt;pre&gt;/**&lt;br /&gt;Function : fn_check_date_if_in_holiday_list&lt;br /&gt;Parameter : p_date as date&lt;br /&gt;Description : Checks if date is Saturday/ Sunday OR in holiday list table.&lt;br /&gt;Dependent : sp_get_next_working_date&lt;br /&gt;**/&lt;br /&gt;&lt;br /&gt;DETERMINISTIC&lt;br /&gt;BEGIN&lt;br /&gt;  DECLARE dayOfWeek INT DEFAULT 0;&lt;br /&gt;  DECLARE result BIT DEFAULT false;&lt;br /&gt;  DECLARE holidayCount INT DEFAULT 0;&lt;br /&gt;&lt;br /&gt;  SET dayOfWeek = DAYOFWEEK(p_date);&lt;br /&gt;  SELECT COUNT(*) from TBLholidays where holiday_date = p_date INTO holidayCount;&lt;br /&gt;&lt;br /&gt;  IF dayOfWeek = 7 or dayOfWeek = 1 or holidayCount &amp;gt; 0 THEN &lt;br /&gt;    SET result = true;&lt;br /&gt;  END IF;&lt;br /&gt;&lt;br /&gt;  RETURN result;&lt;br /&gt;END&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/09/sql-stored-procedures-next-working-date.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-WTcLL6DFPbg/UibW04aZScI/AAAAAAAACGs/mHlzJ-m8kc0/s72-c/Screenshot+from+2013-09-04+12:06:23.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-1880309225654260477</guid><pubDate>Fri, 06 Sep 2013 06:38:00 +0000</pubDate><atom:updated>2013-09-05T23:38:19.213-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Rails</category><category domain="http://www.blogger.com/atom/ns#">Rake</category><category domain="http://www.blogger.com/atom/ns#">Ruby</category><category domain="http://www.blogger.com/atom/ns#">ruby on rails</category><category domain="http://www.blogger.com/atom/ns#">Terminal</category><title>Rails : Tasks : Truncate db with 1 command</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Back to rails is fun. &lt;br /&gt;&lt;br /&gt;Working on some project I wanted to clean the database to clear all junk data added while testing. &lt;br /&gt;&lt;br /&gt;But wanted to do that with 1 command and checking if I can get clear database without opening pgadmin or run several commands like drop/ create/ migrate. And I also added seeds in the project to get default data for functionality.&lt;br /&gt;&lt;br /&gt;I checked &lt;code&gt;rake --tasks&lt;/code&gt;. Check below screen-shot with selected text.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-U3LBhrZOrS4/Uil1Vs5zlWI/AAAAAAAACHA/cwaAjmT4EHI/s1600/Screenshot+from+2013-09-06+11:49:45.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-U3LBhrZOrS4/Uil1Vs5zlWI/AAAAAAAACHA/cwaAjmT4EHI/s320/Screenshot+from+2013-09-06+11:49:45.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;That was the command which I was looking for. It worked. But it thrown error first that it can not drop database as per the notes in &lt;code&gt;--tasks&lt;/code&gt;. But it first truncated/ migrated and at last the seeds were added to the tables. Easy....:). Loved it....:D&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-JeZlFy-dxjQ/Uil3fXWSRmI/AAAAAAAACHM/SRl05GQfV9w/s1600/Screenshot+from+2013-09-06+11:52:29.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-JeZlFy-dxjQ/Uil3fXWSRmI/AAAAAAAACHM/SRl05GQfV9w/s1600/Screenshot+from+2013-09-06+11:52:29.png&quot; height=&quot;161&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/09/rails-tasks-truncate-db-with-1-command.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-U3LBhrZOrS4/Uil1Vs5zlWI/AAAAAAAACHA/cwaAjmT4EHI/s72-c/Screenshot+from+2013-09-06+11:49:45.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-1531875614994043373</guid><pubDate>Wed, 28 Aug 2013 11:21:00 +0000</pubDate><atom:updated>2013-09-05T23:41:15.769-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL</category><title>SQL : CASE statements</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Using conditions in SQL statements is really useful. Specially when we need to compare 1 value based on conditions with multiple columns.&lt;br /&gt;&lt;br /&gt;For example I have 1 table called tasks. Where I need to check the given date parameter should be greater than or equal to multiple columns based on the current tasks category.&lt;br /&gt;&lt;br /&gt;I can easily do that by code. Can be ROR or PHP. But if we can get the data directly from database it gets really fast for any language.&lt;br /&gt;&lt;br /&gt;In this situation CASE statements are really useful.&lt;br /&gt;&lt;br /&gt;In this example I need to compare parameter date to start_date column if category is &#39;appointment&#39; and to end_date if category is &#39;todo&#39;. &lt;pre&gt;&lt;br /&gt;SELECT * FROM tasks &lt;br /&gt;WHERE &#39;2013-09-02&#39; &gt;=&lt;br /&gt;CASE &lt;br /&gt;  WHEN tasks.category=&#39;appointment&#39; THEN (date(start_date))&lt;br /&gt;  WHEN tasks.category=&#39;todo&#39; THEN (date(end_date))&lt;br /&gt;END&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/08/sql-case-statements.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-672873418787407678</guid><pubDate>Tue, 27 Aug 2013 05:33:00 +0000</pubDate><atom:updated>2013-08-26T22:33:57.772-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Node.js</category><category domain="http://www.blogger.com/atom/ns#">PHP</category><category domain="http://www.blogger.com/atom/ns#">Rails</category><category domain="http://www.blogger.com/atom/ns#">Ruby</category><category domain="http://www.blogger.com/atom/ns#">ruby on rails</category><title>Rails/ PHP : Ubuntu : Add autostart on system boot</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;There is never a thought of starting an application if working in PHP.&lt;br /&gt;But for one of the project we were using node.js and if the PC gets restarted we have to manually start the node.js.&lt;br /&gt;&lt;br /&gt;I have done this before for my local rails application previously(&lt;a href=&quot;http://stefanwienert.net/blog/2012/10/24/autostart-rails-apps-with-system-boot-with-ubuntu-upstart-and-rvm/&quot;&gt;http://stefanwienert.net&lt;/a&gt;) and applied the same for this issue.&lt;br /&gt;&lt;br /&gt;First added .conf file  &lt;pre&gt;sudo gedit /etc/init/run_nodejs.conf&lt;/pre&gt; This will open default editor with new file called run_nodejs.conf&lt;br /&gt;Now add following text to the file &lt;pre&gt;&lt;br /&gt;description &quot;Run Node JS&quot;&lt;br /&gt;&lt;br /&gt;start on (net-device-up and local-filesystems)&lt;br /&gt;stop on runlevel [016]&lt;br /&gt;chdir /path_to_nodejs&lt;br /&gt;&lt;br /&gt;setuid user_name  # set to the user, which should run the app&lt;br /&gt;exec sudo -u user_name  &quot;/path_to_nodejs/nodejs.sh&quot;&lt;br /&gt;&lt;br /&gt;respawn&lt;br /&gt;## give up if I respawn 3 times in 60 seconds...&lt;br /&gt;respawn limit 3 60&lt;br /&gt;&lt;/pre&gt; Now create 1 .sh file named nodejs.sh at location /path_to_nodejs.&lt;br /&gt;&lt;br /&gt;and in nodejs.sh add following commands, to start node js services.&lt;br /&gt;&lt;br /&gt;Also give permissions to the file as &lt;code&gt;chmod +x nodejs.sh&lt;/code&gt; to make is executable.&lt;br /&gt;and then just check with (.conf file name for following command) &lt;pre&gt;sudo start run_nodejs&lt;/pre&gt;You can also restart and stop the service.&lt;br /&gt;&lt;br /&gt;As I mentioned I have done this for rails application. &lt;br /&gt;But had 1 issue. By default I have 1.9.3 ruby version for other projects and for only local project I am using 2.0.0.&lt;br /&gt;&lt;br /&gt;In demoapp.sh I have added following code &lt;pre&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;PATH=$PATH:/home/supriya/.rvm/bin&lt;br /&gt;source &quot;/home/supriya/.rvm/scripts/rvm&quot;&lt;br /&gt;source &quot;.rvmrc&quot; &lt;br /&gt;&lt;br /&gt;rvm use 2.0.0&lt;br /&gt;rails s # -p port_u_want -e env_u_want&lt;br /&gt;&lt;/pre&gt; So with these commands after starting my pc I get my local demoapp project always running with 2.0.0 and no worries about the default gemset.&lt;br /&gt;And while working on project I can run log with if any error checking  &lt;pre&gt;sudo tail -f /var/log/upstart/demoapp.log&lt;/pre&gt; &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/08/rails-php-ubuntu-add-autostart-on.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-439397374621952408</guid><pubDate>Tue, 23 Jul 2013 07:30:00 +0000</pubDate><atom:updated>2013-09-09T22:24:02.286-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Collection</category><category domain="http://www.blogger.com/atom/ns#">Tutorials</category><title>Collection : Thenewboston (Video Tutorials)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Most of people find video tutorials very helpful more than reading books. As we understand more with watching practical examples.  &lt;br /&gt;&lt;br /&gt;Looking forward to other technologies I found a very useful site &lt;a href=&quot;http://thenewboston.org/&quot; target=&quot;_blank&quot;&gt;TheNewBoston&lt;/a&gt; by &lt;a href=&quot;http://thenewboston.org/about.php&quot; target=&quot;_blank&quot;&gt;Bucky Roberts&lt;/a&gt;, who provides video tutorials for multiple languages like java, android, php, ruby and more. &lt;br /&gt;Just go to &lt;a href=&quot;http://thenewboston.org/tutorials.php&quot; target=&quot;_blank&quot;&gt;tutorials&lt;/a&gt; section and check the list, for technologies you want to learn. &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/07/collection-thenewboston-video-tutorials.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-3779893117320948424</guid><pubDate>Mon, 17 Jun 2013 06:39:00 +0000</pubDate><atom:updated>2013-06-16T23:39:04.195-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PHP</category><title>PHP : Excel Reader</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Reading excel sheets now a days is not that big challenge, but reading it with very advanced formulas is definitely a very big challenge. One of team really spent a very pressured day to work on this functionality. &lt;br /&gt;&lt;br /&gt;We used &lt;a href=&quot;http://phpexcel.codeplex.com/&quot; target=&quot;_blank&quot;&gt;PHPExcel&lt;/a&gt; but was not reading values from other sub-sheet while performing getCalculatedValue(). Everything else was working fine. Like dynamically adding new values and generating the excel. After opening the new excel it worked like the original with new values. But the main functionality which we wanted, was getCalculatedValue() to display the calculations on web page. &lt;br /&gt;&lt;br /&gt;After checking other plugins we found one more excel reader at &lt;a href=&quot;http://devzone.zend.com/27/reading-and-writing-spreadsheets-with-php/&quot; target=&quot;_blank&quot;&gt;devzone.zend.com&lt;/a&gt;. Tried with our excel sheet which worked like a charm.&lt;br /&gt;&lt;br /&gt;Really useful for getting advanced formulas calculated values. There is also a excel writer but I didn&#39;t check it yet. &lt;br /&gt;The only limitation to this plugin is that it do not work with xlsx file.  &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/06/php-excel-reader.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-2710563246793849043</guid><pubDate>Thu, 30 May 2013 07:52:00 +0000</pubDate><atom:updated>2013-05-30T00:52:34.010-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CakePHP</category><category domain="http://www.blogger.com/atom/ns#">PHP</category><category domain="http://www.blogger.com/atom/ns#">Rails</category><title>CakePHP = Rails Framework</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;As I said in previous posts I really miss rails framework while working for PHP web applications.  Just looking around the best sites on rails I found that &lt;a href=&quot;http://cakephp.org/&quot; target=&quot;_blank&quot;&gt;CakePHP&lt;/a&gt; has a similar framework like rails.  &lt;br /&gt;&lt;br /&gt;Was really excited to get hands on it.  Downloaded the latest version of the framework and started the application.  But crashed with several warnings like &#39;Warning: _cake_core_ cache was unable to write...&#39; &lt;br /&gt;&lt;br /&gt;After reading warnings and checking around for solution, found, that need to provide writable permissions to tmp in app folder  &lt;code&gt;chmod -R 777 app/tmp&lt;/code&gt; which really helped for starting the project smoothly.  Also found the &lt;a href=&quot;http://stackoverflow.com/a/9379989&quot; target=&quot;_blank&quot;&gt;answer&lt;/a&gt; which is helpful for other errors. &lt;br /&gt;&lt;br /&gt;Until now I found that it contains functions similar to rails like beforeFilter() and so on, although I am not yet familiar with this framework. But it contains many function which I tried to build in my framework like render or helpers.  &lt;br /&gt;&lt;br /&gt;I am really going to love this if it works like rails, and will have no complaints about PHP. &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/05/cakephp-rails-framework.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-6069574370864556005</guid><pubDate>Fri, 17 May 2013 04:32:00 +0000</pubDate><atom:updated>2013-05-28T22:11:34.595-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Question and Answers</category><category domain="http://www.blogger.com/atom/ns#">Rails</category><category domain="http://www.blogger.com/atom/ns#">Rails 3</category><category domain="http://www.blogger.com/atom/ns#">Ruby</category><category domain="http://www.blogger.com/atom/ns#">ruby on rails</category><title> QA : 3 : How to implement the twitter authentication in rails 3.2?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Question from Bala Chandar :  &lt;p&gt;&lt;b&gt;How to implement the twitter authentication in rails 3.2?&lt;/b&gt;&lt;/p&gt;Answer :  &lt;p&gt;There is a gem available for twitter authentication &lt;a href=&quot;https://github.com/pelle/oauth-plugin#readme&quot; target=&quot;_blank&quot;&gt;oauth-plugin&lt;/a&gt; by &lt;a href=&quot;https://github.com/pelle&quot; target=&quot;_blank&quot;&gt;Pelle Braendgaard&lt;/a&gt;&lt;p&gt; Please check the link &lt;a href=&quot;https://github.com/pelle/oauth-plugin#configuration&quot; target=&quot;_blank&quot;&gt;Twitter Authentication Settings&lt;/a&gt;.  &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/05/qa-3-how-to-implement-twitter.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-8036714054516579494</guid><pubDate>Fri, 12 Apr 2013 10:54:00 +0000</pubDate><atom:updated>2013-04-19T06:29:54.148-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Collection</category><category domain="http://www.blogger.com/atom/ns#">Collection : Javascript</category><category domain="http://www.blogger.com/atom/ns#">javascript</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Collection : Javascript : Using select tags for date selection</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Now a days generally most of sites use calendar dialog boxes for selecting a date in forms. We get all functionality for that including leap years and 30 or 31 days depending on the month. But how can we get these all when we are using simple drop downs or select is the question. Well we can use javascript to validate the fields. &lt;br /&gt;In this post we will use jquery for validating 3 dropdowns which are year, month and date. As I was working on PHP the example will hold PHP code. &lt;br /&gt;&lt;br /&gt;In this example consider that we are working on employee joining form and we want to add a joining date. &lt;br /&gt;&lt;b&gt;In html&lt;/b&gt;&lt;div class=&quot;highlight-code&quot;&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;div id=&quot;joiningDate&quot;&amp;gt;&lt;br /&gt;  &amp;lt;?php &lt;br /&gt;    $joining_date = select_tag(&quot;employees[joining_date][month]&quot;, unserialize(MONTHS), date(&#39;F&#39;), array(&#39;class&#39; =&gt; &#39;month&#39;));&lt;br /&gt;    $joining_date .= select_tag(&quot;employees[joining_date][date]&quot;, unserialize(DAYS), date(&#39;j&#39;), array(class&#39; =&gt; &#39;date&#39;));&lt;br /&gt;    $joining_date .= select_tag(&quot;employees[joining_date][year]&quot;, array(&quot;2012&quot;, &quot;2013&quot;, &quot;2014&quot;, &quot;2015&quot;, &#39;2016&#39;, &#39;2017&#39;), date(&#39;Y&#39;), array(&#39;class&#39; =&gt; &#39;year&#39;));&lt;br /&gt;    echo $joining_date;&lt;br /&gt;  ?&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;  Note : For &lt;code&gt;select_tag&lt;/code&gt; please check &lt;a href=&quot;http://www.supriyasurve.com/2012/11/collection-php-selecttag.html&quot; target=&quot;_blank&quot;&gt;Collection : PHP : select_tag&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Define some constants for long arrays.&lt;br /&gt;&lt;b&gt;Constants &lt;/b&gt;&lt;pre&gt;&lt;br /&gt;defined(&#39;MONTHS&#39;) or define(&quot;MONTHS&quot;, serialize(array(&#39;January&#39;, &#39;February&#39;, &#39;March&#39;, &#39;April&#39;, &#39;May&#39;, &#39;June&#39;, &#39;July&#39;, &#39;August&#39;, &#39;September&#39;, &#39;October&#39;, &#39;November&#39;, &#39;December&#39;)));&lt;br /&gt;defined(&#39;DAYS&#39;) or define(&#39;DAYS&#39;, serialize(array(&#39;01&#39;, &#39;02&#39;, &#39;03&#39;, &#39;04&#39;, &#39;05&#39;, &#39;06&#39;, &#39;07&#39;, &#39;08&#39;, &#39;09&#39;, &#39;10&#39;, &#39;11&#39;, &#39;12&#39;, &#39;13&#39;, &#39;14&#39;, &#39;15&#39;, &#39;16&#39;, &#39;17&#39;, &#39;18&#39;, &#39;19&#39;, &#39;20&#39;, &#39;21&#39;, &#39;22&#39;, &#39;23&#39;, &#39;24&#39;, &#39;25&#39;, &#39;26&#39;, &#39;27&#39;, &#39;28&#39;, &#39;29&#39;, &#39;30&#39;, &#39;31&#39;)));&lt;br /&gt;&lt;/pre&gt;Finally the javascript function which will actually play the magic in html. Check the comments for explanation. In Javascript file &lt;pre&gt;&lt;br /&gt;$(document).ready(function(){&lt;br /&gt;  validateDateFields(&#39;#joiningDate&#39;);&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;function validateDateFields(divID){&lt;br /&gt;  // Jquery objects of date and month fields in new function&lt;br /&gt;  var dateField = $(divID).find(&#39;select.date&#39;);&lt;br /&gt;  var monthField = $(divID).find(&#39;select.month&#39;);&lt;br /&gt;&lt;br /&gt;  // Months hash for adding or removing the options tags &lt;br /&gt;  var monthsHash = {&lt;br /&gt;    &#39;January&#39; : 1, &lt;br /&gt;    &#39;February&#39; : 2, &lt;br /&gt;    &#39;March&#39; : 3, &lt;br /&gt;    &#39;April&#39; : 4, &lt;br /&gt;    &#39;May&#39; : 5, &lt;br /&gt;    &#39;June&#39; : 6, &lt;br /&gt;    &#39;July&#39; : 7, &lt;br /&gt;    &#39;August&#39; : 8, &lt;br /&gt;    &#39;September&#39; : 9, &lt;br /&gt;    &#39;October&#39; : 10, &lt;br /&gt;    &#39;November&#39; : 11, &lt;br /&gt;    &#39;December&#39; : 12&lt;br /&gt;  };&lt;br /&gt;  // Months with 31 days&lt;br /&gt;  var fullMonth = [1, 3, 5, 7, 8, 10, 12];&lt;br /&gt;  &lt;br /&gt;  // Current values of the fields&lt;br /&gt;  var dateVal = dateField.val();&lt;br /&gt;  var monthVal = monthField.val();&lt;br /&gt;  var yearVal = $(divID).find(&#39;select.year&#39;).val();&lt;br /&gt;  &lt;br /&gt;  // Check current year if leap year&lt;br /&gt;  var isLeap = new Date(yearVal, 1, 29).getMonth() == 1;&lt;br /&gt;  // Date field child node with options 29, 30 and 31&lt;br /&gt;  var dateOption29 = dateField.children(&#39;option[value=29]&#39;);&lt;br /&gt;  var dateOption30 = dateField.children(&#39;option[value=30]&#39;);&lt;br /&gt;  var dateOption31 = dateField.children(&#39;option[value=31]&#39;);&lt;br /&gt;  // defining other variable &lt;br /&gt;  var appendOptions;&lt;br /&gt;    &lt;br /&gt;  if(monthsHash[monthVal]==2){&lt;br /&gt;    // First : If selected month in 2 or February&lt;br /&gt;    if(isLeap){&lt;br /&gt;      // If the selected year is leap year&lt;br /&gt;      if(dateOption29.length == 0){&lt;br /&gt;        // If date field child nodes do not have any option with value 29&lt;br /&gt;        dateField.append(&#39;&amp;lt;option value=29&amp;gt;29&amp;lt;/option&amp;gt;&#39;);        &lt;br /&gt;      }&lt;br /&gt;    }else{&lt;br /&gt;      // If its not a leap year remove date field child node option with value 29&lt;br /&gt;      dateOption29.remove();&lt;br /&gt;    }&lt;br /&gt;    // In month 2 or february by default remove date field child options with value 30 and 31&lt;br /&gt;    dateOption30.remove();&lt;br /&gt;    dateOption31.remove();&lt;br /&gt;  }else if($.inArray(monthsHash[monthVal], fullMonth) &amp;gt; -1){&lt;br /&gt;    // If the selected month is of 31 days &lt;br /&gt;    if(dateOption31.length == 0){&lt;br /&gt;      // If option with value 31 do not exist &lt;br /&gt;      if(dateOption29.length == 0){&lt;br /&gt;        // If option with value 29 do not exist &lt;br /&gt;        appendOptions += &#39;&amp;lt;option value=29&amp;gt;29&amp;lt;/option&amp;gt; &amp;lt;option value=30&amp;gt;30&amp;lt;/option&amp;gt;&#39;;&lt;br /&gt;      }else if(dateOption30.length == 0){&lt;br /&gt;        // If option with value 30 do not exist &lt;br /&gt;        appendOptions += &#39;&amp;lt;option value=30&amp;gt;30&amp;lt;/option&amp;gt;&#39;;&lt;br /&gt;      }&lt;br /&gt;      appendOptions += &#39;&amp;lt;option value=31&amp;gt;31&amp;lt;/option&amp;gt;&#39;;&lt;br /&gt;      // append options which do not exist in date field child nodes&lt;br /&gt;      dateField.append(appendOptions);&lt;br /&gt;    }&lt;br /&gt;  }else{&lt;br /&gt;    // If the selected month is of 30 days &lt;br /&gt;    if(dateOption29.length == 0){&lt;br /&gt;      // If option with value 29 do not exist &lt;br /&gt;      dateField.append(&#39;&amp;lt;option value=29&amp;gt;29&amp;lt;/option&amp;gt; &amp;lt;option value=30&amp;gt;30&amp;lt;/option&amp;gt;&#39;);&lt;br /&gt;    }else if(dateOption30.length == 0){&lt;br /&gt;      // If option with value 30 do not exist &lt;br /&gt;      dateField.append(&#39;&amp;lt;option value=30&amp;gt;30&amp;lt;/option&amp;gt;&#39;);&lt;br /&gt;    }else if(dateOption31.length &amp;gt; 0){&lt;br /&gt;      // If option with value 31 exist&lt;br /&gt;      dateOption31.remove();&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;  // Add other code for updating any values here.&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/04/collection-javascript-using-select-tags.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-8153592208810293441</guid><pubDate>Fri, 29 Mar 2013 05:45:00 +0000</pubDate><atom:updated>2013-03-28T22:46:58.195-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">APN</category><category domain="http://www.blogger.com/atom/ns#">PHP</category><title>PHP : Apple Push Notification (APN)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Hope you have read my previous post for &lt;a href=&quot;http://supriya-surve.blogspot.in/2012/08/rails-3-apn-on-rails.html&quot;&gt;Rails 3 : APN on Rails &lt;/a&gt; in which I tried apn_on_rails gem for sending notification to apple devices. I have also added the link for &lt;a href=&quot;http://maniacdev.com/2011/05/tutorial-ios-push-notification-services-for-beginners/&quot;&gt;ManiacDev.Com&lt;/a&gt; in which you will get the steps for certification creation which are the most important steps for notifications.&lt;br /&gt;&lt;br /&gt;Now for sending notification in PHP there is a great example available at &lt;a href=&quot;http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12&quot;&gt;raywenderlich.com : Apple Push Notification Services Tutorial: Part 1/2&lt;/a&gt;. You can download the example file at from given link in the post.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-dOgZCll9veU/UVUpT-Ld1oI/AAAAAAAABoo/chaK9QFaMkE/s1600/downloadlink.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;174&quot; src=&quot;http://1.bp.blogspot.com/-dOgZCll9veU/UVUpT-Ld1oI/AAAAAAAABoo/chaK9QFaMkE/s640/downloadlink.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;This is a PHP sample code. Just change the deviceToken, passphrase and message variables. Make changes as per your requirement. But again I faced some certification errors which were : &lt;u&gt;&lt;code&gt;ssl_connect returned=1 errno=0 state=sslv3 read finished a sslv3 alert certificate unknown&lt;/code&gt;&lt;/u&gt; and &lt;u&gt;&lt;code&gt;Neither PUB key nor PRIV key:: nested asn1 error&lt;/code&gt;&lt;/u&gt;. Nothing else got the wrong certificate generated. Just get the required certificate and you are good to go.&lt;br /&gt;I really loved it.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-kuMukTLEv8M/UVFe_ZWm9tI/AAAAAAAABoQ/LBXJpmwQ7Ek/s1600/notification.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;116&quot; src=&quot;http://2.bp.blogspot.com/-kuMukTLEv8M/UVFe_ZWm9tI/AAAAAAAABoQ/LBXJpmwQ7Ek/s640/notification.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/03/php-apple-push-notification-apn.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-dOgZCll9veU/UVUpT-Ld1oI/AAAAAAAABoo/chaK9QFaMkE/s72-c/downloadlink.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-3490404523838833013</guid><pubDate>Tue, 05 Mar 2013 09:02:00 +0000</pubDate><atom:updated>2013-03-06T01:12:07.897-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Code</category><category domain="http://www.blogger.com/atom/ns#">javascript</category><category domain="http://www.blogger.com/atom/ns#">Rails</category><category domain="http://www.blogger.com/atom/ns#">Rails 3</category><category domain="http://www.blogger.com/atom/ns#">Ruby</category><category domain="http://www.blogger.com/atom/ns#">ruby on rails</category><title>Rails : Code : Split Records</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I was very much impressed when I saw the split entry functionality in time-sheet project we were using. I wanted to try out same in ROR. But I will also try this out in PHP now. First we will look at ROR code.&lt;br /&gt;&lt;br /&gt;Assume that we are creating a time-sheet project and we need to split the duration and considering, we already have the rails project with authentication, and now we generate a new section &#39;Time Records&#39;, which will store the records of users with duration.&lt;br /&gt;I am running scaffold so we will have all views, controller and model.&lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt; rails g scaffold time_records description:text duration:float parent_id:integer&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-Ge8nTQZ3Ub8/UTWVGgfj_DI/AAAAAAAABnU/yiaPqXpfGqs/s1600/migration.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-Ge8nTQZ3Ub8/UTWVGgfj_DI/AAAAAAAABnU/yiaPqXpfGqs/s640/migration.png&quot; height=&quot;254&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Run migration to add table in database. &lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt; rake db:migrate&lt;br /&gt;&lt;/pre&gt;Now we will add new record&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-o2xhOS6eiR8/UTWVPT3NwbI/AAAAAAAABnc/g_HJSs8ytCo/s1600/form.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-o2xhOS6eiR8/UTWVPT3NwbI/AAAAAAAABnc/g_HJSs8ytCo/s640/form.png&quot; height=&quot;350&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This is a basic setup what we need till now. Once this base is complete we will start with actual requirement.  Now first we need to add a anchor tag (link) with which the functionality will work. SO I have added it in index page.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-M0aPK12Hzl4/UTWVUWAncGI/AAAAAAAABnk/tjnBXyG9UYw/s1600/entry.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-M0aPK12Hzl4/UTWVUWAncGI/AAAAAAAABnk/tjnBXyG9UYw/s640/entry.png&quot; height=&quot;220&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In this example I am using javascript function for ajax call but it is not complusory, we can directly use send the user to the form page with out javascript.  So I am using onclick attribute for calling a function.&lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;&amp;lt;%= link_to &#39;Split&#39;, &#39;#&#39;, :onClick =&amp;gt;&amp;nbsp;&quot;split_duration_for_entry(&#39;split_#{time_record.id}&#39;, #{time_record.id})&quot; %&amp;gt;&lt;/pre&gt;In that function&lt;br /&gt;&lt;pre class=&quot;brush:js&quot;&gt;/* this is for spliting the duration */&lt;br /&gt;function split_duration_for_entry( div, id ){&lt;br /&gt;  var divid = &quot;#&quot;+div&lt;br /&gt;  var classes = jQuery(&quot;.split_box&quot;);&lt;br /&gt;&lt;br /&gt;  jQuery(classes).each(function(){&lt;br /&gt;    var thisid = $(this).parent(&#39;td&#39;).attr(&#39;id&#39;)&lt;br /&gt;    var v = jQuery(&quot;#&quot;+thisid).next().val();&lt;br /&gt;    jQuery(&quot;#&quot;+thisid).html(&quot;&amp;lt;a href=&#39;#&#39; onClick=\&quot;split_duration_for_entry(&#39;&quot;+thisid+&quot;&#39;, &quot;+id+&quot;)\&quot;&amp;gt;Split&amp;lt;/a&amp;gt;&quot;)&lt;br /&gt;  });&lt;br /&gt;&lt;br /&gt;  actual_duration = $(&#39;#split_&#39;+id).prev(&#39;td&#39;).html();&lt;br /&gt;  jQuery.ajax({&lt;br /&gt;    type: &#39;GET&#39;,&lt;br /&gt;    url: &#39;/time_records/split_entries_div&#39;,&lt;br /&gt;    data:{&#39;record_id&#39; : id, &#39;actual_duration&#39;: actual_duration},&lt;br /&gt;    success: function(transform){&lt;br /&gt;      jQuery(divid).html(transform);&lt;br /&gt;    }&lt;br /&gt;  });&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So this function will  &lt;br /&gt;&lt;ul&gt;&lt;li&gt;Hide opened split duration divs if open.&lt;/li&gt;&lt;li&gt;Send the parameters(id and duration) to split_entries_div action in our controller.&lt;/li&gt;&lt;li&gt;Once the action is called display the partial with data and links.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;In controller  &lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;def split_entries_div&lt;br /&gt;  id = params[:record_id].to_i&lt;br /&gt;  time_record = TimeRecord.find(id)&lt;br /&gt;  render partial: &quot;split_entries&quot;, locals: {record_id: id, old_duration: time_record.duration.to_f}, layout: false&lt;br /&gt;end &lt;/pre&gt;So here comes the partial.  &lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;  &lt;br /&gt;&amp;lt;div class=&quot;split_box&quot;&amp;gt;&lt;br /&gt;  &amp;lt;div&amp;gt;&lt;br /&gt;    &amp;lt;%= hidden_field_tag &quot;actual_duration#{record_id}&quot;, params[:actual_duration] %&amp;gt;&lt;br /&gt;    &amp;lt;%= text_field_tag &quot;old_duration_#{record_id}&quot;, params[:actual_duration], size: 5 %&amp;gt;&lt;br /&gt;    &amp;lt;%= text_field_tag &quot;new_duration_#{record_id}&quot;, 0, size: 5 %&amp;gt;&lt;br /&gt;  &amp;lt;/div&amp;gt;&lt;br /&gt;  &amp;lt;div&amp;gt;&lt;br /&gt;    &amp;lt;%= link_to &#39;Split&#39;, &quot;#this&quot;, onClick: &quot;split_entries(this, #{record_id})&quot; %&amp;gt;&lt;br /&gt;    &amp;lt;%= link_to &quot;Cancel&quot;, &quot;#this&quot;, onClick: &quot;cancel_split_entry(this, #{record_id})&quot; %&amp;gt;&lt;br /&gt;  &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/pre&gt;In CSS &lt;br /&gt;&lt;pre&gt;.split_box{&lt;br /&gt;  background: none repeat scroll 0 0 #EFEFEF;&lt;br /&gt;  border: 4px solid #CCCCCC;&lt;br /&gt;  width: 100px;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In this partial we will have  &lt;br /&gt;&lt;ul&gt;&lt;li&gt;2 main text fields which will contain the old duration for updating the original record and new duration for which we will be creating a new record.&lt;/li&gt;&lt;li&gt;1 hidden field to keep the original duration so if the validation is called then we can again store the original duration value to old duration field.&lt;/li&gt;&lt;li&gt;2 anchor tags for calling actual functionality and canceling the div poped up.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-hppjlrH0Sxs/UTWVbauXsAI/AAAAAAAABns/QKT45XdvsYg/s1600/with+partial.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-hppjlrH0Sxs/UTWVbauXsAI/AAAAAAAABns/QKT45XdvsYg/s640/with+partial.png&quot; height=&quot;274&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;First the main functionality. Actual spliting/ updating the entry will be performed if the user clicks the split link. On which &#39;split_entries&#39; function is called by passing record&#39;s id.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;function split_entries( id ){&lt;br /&gt;  var newrecrd;&lt;br /&gt;  var new_record_val = jQuery(&quot;#new_duration_&quot;+id).val();&lt;br /&gt;  var old_record_val = jQuery(&quot;#old_duration_&quot;+id).val();&lt;br /&gt;  &lt;br /&gt;  var actual = $(&quot;#actual_duration&quot;+id).val();&lt;br /&gt;  var total = parseFloat(old_record_val) + parseFloat(new_record_val);&lt;br /&gt;  &lt;br /&gt;  if(parseFloat(actual) &amp;lt; total ) {&lt;br /&gt;    alert(&quot;Total duration for OLD and New records can not be greater than original value&quot;);&lt;br /&gt;    jQuery(&quot;#old_duration_&quot;+id).val(actual);&lt;br /&gt;    jQuery(&quot;#new_duration_&quot;+id).val(0);&lt;br /&gt;    return false; &lt;br /&gt;  }else if(parseFloat(old_record_val) &amp;lt; 24){&lt;br /&gt;    if(new_record_val==0 || new_record_val==&quot;&quot;){&lt;br /&gt;      newrecrd = false&lt;br /&gt;    }else{&lt;br /&gt;      newrecrd = true&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    cancel_split_entry(id);&lt;br /&gt;&lt;br /&gt;    jQuery.ajax({&lt;br /&gt;      type: &#39;GET&#39;,&lt;br /&gt;      url: &#39;/time_records/split_entries&#39;,&lt;br /&gt;      data:{&lt;br /&gt;        &#39;newrecrd&#39; : newrecrd,&lt;br /&gt;        &#39;old_id&#39; : id,&lt;br /&gt;        &#39;old_duration&#39;: parseFloat(old_record_val).toFixed(2),&lt;br /&gt;        &#39;new_record_val&#39; : parseFloat(new_record_val).toFixed(2)&lt;br /&gt;      },&lt;br /&gt;      success: function(transport){&lt;br /&gt;        window.location.reload();&lt;br /&gt;      }&lt;br /&gt;    });&lt;br /&gt;  }else {&lt;br /&gt;    alert(&quot;Duration can not be greater than 24 hrs. Enter valid duration&quot;);&lt;br /&gt;    return false;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I have added some validations to this functionality  &lt;br /&gt;&lt;ul&gt;&lt;li&gt;Duration can not be greater than 24 hours OR&lt;/li&gt;&lt;li&gt;The total of both value can not be greater that the original duration&lt;/li&gt;&lt;/ul&gt;We can just remove/ modify these validation as per our requirement&lt;br /&gt;&lt;br /&gt;Other than that  &lt;br /&gt;&lt;ul&gt;&lt;li&gt;If it passes the validation it will first check if the new duration value should not be blank or equal to 0. This will set true or false to local variable &#39;newrecrd&#39; which will be passes to the action as parameter via ajax.&lt;/li&gt;&lt;li&gt;Original record is will be passes and old_id.&lt;/li&gt;&lt;li&gt;Both new duration and old duration will be passed to the action.&lt;/li&gt;&lt;/ul&gt;&lt;pre&gt;  &lt;br /&gt;# split duration&lt;br /&gt;  def split_entries&lt;br /&gt;    @time_record = TimeRecord.find(params[:old_id].to_i)&lt;br /&gt;    description = @time_record.description&lt;br /&gt;    @time_record.update_attributes(description: description, duration: params[:old_duration])&lt;br /&gt;    if params[:newrecrd]==&#39;true&#39;&lt;br /&gt;      TimeRecord.create(description: description, duration: params[:new_record_val], parent_id: @time_record.id)&lt;br /&gt;    end&lt;br /&gt;    redirect_to :back&lt;br /&gt;  end&lt;br /&gt;&lt;/pre&gt;In which   get the original record and update the duration&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;if &lt;code&gt;params[:newrecrd]&lt;/code&gt; is true then create a new record with new duration value.&lt;/li&gt;&lt;/ul&gt;And now in routes add &lt;br /&gt;&lt;pre&gt;resources :time_records do &lt;br /&gt;  collection do &lt;br /&gt;    get &#39;split_entries&#39;&lt;br /&gt;    get &#39;split_entries_div&#39;&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-8tCGckgm6yk/UTWVtViQ_4I/AAAAAAAABn8/CkgoiUyavLM/s1600/Screenshot+from+2013-03-05+12:13:00.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-8tCGckgm6yk/UTWVtViQ_4I/AAAAAAAABn8/CkgoiUyavLM/s640/Screenshot+from+2013-03-05+12:13:00.png&quot; height=&quot;272&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Once the set up is done restart the application and check the output&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-o2E1QVwDhxg/UTWVkJpje8I/AAAAAAAABn0/oZCISrazes4/s1600/output.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-o2E1QVwDhxg/UTWVkJpje8I/AAAAAAAABn0/oZCISrazes4/s640/output.png&quot; height=&quot;252&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Get the code at &lt;a href=&quot;https://github.com/supriyassurve/Split-Records&quot;&gt;Github : Split-Records&lt;/a&gt;&lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/03/rails-code-split-records.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-Ge8nTQZ3Ub8/UTWVGgfj_DI/AAAAAAAABnU/yiaPqXpfGqs/s72-c/migration.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-3284497605249137576</guid><pubDate>Fri, 01 Mar 2013 08:23:00 +0000</pubDate><atom:updated>2013-03-01T00:23:09.581-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Collection</category><category domain="http://www.blogger.com/atom/ns#">css</category><category domain="http://www.blogger.com/atom/ns#">html</category><category domain="http://www.blogger.com/atom/ns#">Web Development</category><title>Collection : Dabblet</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;There are many tools now a days to check your HTML and CSS code directly in browser for quick development. Tools like Firebug or inbuilt developer tools in browsers helps a lot, to check instant changes and don&#39;t have to wait for loading the page each time for small changes.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://dabblet.com/&quot; target=&quot;_blank&quot;&gt;Dabblet&lt;/a&gt; is also a very useful tool to develop and test your CSS and HTML code.   &lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-kQtVEM2oTpg/UTBJvrlC3aI/AAAAAAAABmc/_SR6dqAwfHg/s1600/1362118965666-uploadscreenshot-dot-com.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;352&quot; src=&quot;http://4.bp.blogspot.com/-kQtVEM2oTpg/UTBJvrlC3aI/AAAAAAAABmc/_SR6dqAwfHg/s640/1362118965666-uploadscreenshot-dot-com.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This supports the modern versions of browsers like chrome, firefox and safari. But do not support IE.  &lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-Z8K8Rx4_cdY/UTBOHyutp3I/AAAAAAAABm4/V1Wj8kUZQh8/s1600/dabbleIE.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;http://1.bp.blogspot.com/-Z8K8Rx4_cdY/UTBOHyutp3I/AAAAAAAABm4/V1Wj8kUZQh8/s640/dabbleIE.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can get more information on &lt;a href=&quot;http://dabblet.com/help/index.html&quot; target=&quot;_blank&quot;&gt;dabbel help page&lt;/a&gt;. Advantage of this is that you don&#39;t have to keep the file on local machine. You can just save it on the &lt;a href=&quot;https://gist.github.com/&quot; target=&quot;_blank&quot;&gt;gist.github.com&lt;/a&gt; as anonymous or you can also sign in with your account for storing the changes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-Qbx_bGBNvGg/UTBPxpNLsRI/AAAAAAAABnE/GXAaS_lg-3E/s1600/1362119295187-uploadscreenshot-dot-com.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;354&quot; src=&quot;http://1.bp.blogspot.com/-Qbx_bGBNvGg/UTBPxpNLsRI/AAAAAAAABnE/GXAaS_lg-3E/s640/1362119295187-uploadscreenshot-dot-com.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;The output can be viewed at &lt;a href=&quot;http://www.blogger.com/dabblet.com/gist&quot; target=&quot;_blank&quot;&gt;http://dabblet.com/gist/5062815&lt;/a&gt; or you can just view the code at &lt;a href=&quot;https://gist.github.com/anonymous/5062815/&quot;&gt;github.com/anonymous/5062815&lt;/a&gt;. Also you can view the whole page result at &lt;a href=&quot;http://result.dabblet.com/gist/5062815/&quot;&gt;result.dabblet.com&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-2n3bp3jOnFE/UTBNlLFA0uI/AAAAAAAABmw/qQjU8tR46uE/s1600/Screenshot+from+2013-03-01+12:10:35.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;380&quot; src=&quot;http://1.bp.blogspot.com/-2n3bp3jOnFE/UTBNlLFA0uI/AAAAAAAABmw/qQjU8tR46uE/s640/Screenshot+from+2013-03-01+12:10:35.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now as I have mentioned earlier that dabble do not support IE but you can just check the output after storing the changes to github.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-ZS2xBbr6ySI/UTBNJAdkCgI/AAAAAAAABmo/Of8SytBCpyw/s1600/resultIE.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;http://2.bp.blogspot.com/-ZS2xBbr6ySI/UTBNJAdkCgI/AAAAAAAABmo/Of8SytBCpyw/s640/resultIE.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt; &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/03/collection-dabblet.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-kQtVEM2oTpg/UTBJvrlC3aI/AAAAAAAABmc/_SR6dqAwfHg/s72-c/1362118965666-uploadscreenshot-dot-com.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-7764563644504733157</guid><pubDate>Fri, 22 Feb 2013 10:53:00 +0000</pubDate><atom:updated>2013-02-22T03:08:39.331-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PHP</category><title>PHP : MVC : Framework</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I really missed rails framework and available helpers a lot while working on PHP. &lt;br /&gt;But I really learned a lot while finding the similar functionalities in PHP. &lt;br /&gt;I tried the some of the available PHP frameworks but didn&#39;t find anything like rails.&lt;br /&gt;&lt;br /&gt;So I started to define helpers and functions for my current PHP project. &lt;br /&gt;Currently it&#39;s not complete but working with minor bugs. &lt;br /&gt;Bugs like &lt;br /&gt;&amp;nbsp; If I try to call view without .php extension it works fine, but with .php extension it crashes.&lt;br /&gt;&lt;br /&gt;Still missing the actual flow of MVC (model, views and controller)(need to work on it). &lt;br /&gt;&lt;br /&gt; Folder structure for this application is as follows:&lt;br /&gt; &lt;pre&gt;  &lt;br /&gt;app    &lt;br /&gt;    |- assets    &lt;br /&gt;        |- fonts&lt;br /&gt;        |- images&lt;br /&gt;        |- javascripts&lt;br /&gt;        |- stylesheets&lt;br /&gt;    |- classes&lt;br /&gt;    |- helpers&lt;br /&gt;    |- views&lt;br /&gt;        |- Folder&lt;br /&gt;  config&lt;br /&gt;    |- config.php&lt;br /&gt;    |- constants.php&lt;br /&gt;    |- database.php&lt;br /&gt;    |- path_includes.php&lt;br /&gt;    |- routes.php&lt;br /&gt;  docs&lt;br /&gt;  includes&lt;br /&gt;    |- classes&lt;br /&gt;        |- application.class.php&lt;br /&gt;    |- helpers&lt;br /&gt;        |- common_helper.php&lt;br /&gt;    |- php&lt;br /&gt;        |- active_queries.php&lt;br /&gt;        |- authentication.php&lt;br /&gt;        |- base.php&lt;br /&gt;        |- structure.php&lt;br /&gt;        |- word_plurals.php&lt;br /&gt;  lib&lt;br /&gt;  index.php&lt;br /&gt;  login.php&lt;br /&gt;  logout.php&lt;br /&gt;  navigation.php&lt;br /&gt;  session_settings.php&lt;br /&gt;  signin.php&lt;br /&gt;  ReadMe.txt&lt;br /&gt;  &lt;/pre&gt;&lt;/div&gt; Need to do lots of changes.&lt;br /&gt;I have uploaded the code to &lt;a href=&quot;https://github.com/supriyassurve/MVC-PHP&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt;. If anyone can help me to solve the current bug that will be a great help.&lt;br /&gt;&lt;br /&gt;</description><link>http://blog.supriyasurve.com/2013/02/php-mvc-framework.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-6731991768113068108</guid><pubDate>Tue, 15 Jan 2013 06:00:00 +0000</pubDate><atom:updated>2013-01-14T22:00:36.862-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">API</category><category domain="http://www.blogger.com/atom/ns#">PHP</category><title>PHP : API : Documentation</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Documentation is very necessary for every project. I usually add comments for every function in my project but getting the whole summary to one place was important. &lt;br /&gt;&lt;br /&gt;In rails I knew how to do it but in php? &lt;br /&gt;I came across apigen for php project &#39;professional API documentation tool&#39;. &lt;br /&gt;Really great to see the result. Loved it.&lt;br /&gt;&lt;br /&gt;So we need to download the pack from &lt;a href=&quot;http://apigen.org/##overview&quot; target=&quot;_blank&quot;&gt;apigen.org&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-hgkTm_lJXNo/UPTuxXYuhHI/AAAAAAAABlg/exwYih6JlKA/s1600/apigen.org.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;384&quot; src=&quot;http://2.bp.blogspot.com/-hgkTm_lJXNo/UPTuxXYuhHI/AAAAAAAABlg/exwYih6JlKA/s640/apigen.org.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Extract it to required path and then follow the steps given at &lt;a href=&quot;https://blogs.oracle.com/netbeansphp/entry/apigen_support_added&quot; target=&quot;_blank&quot;&gt;blogs.oracle.com&lt;/a&gt;. Nice post. &lt;br /&gt;&lt;br /&gt;Thats it and we are ready with the api for our projects.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-qLmXPYQ9Qv8/UPTvUTjGnvI/AAAAAAAABl4/lItppIf-CHE/s1600/docs.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;428&quot; src=&quot;http://2.bp.blogspot.com/-qLmXPYQ9Qv8/UPTvUTjGnvI/AAAAAAAABl4/lItppIf-CHE/s640/docs.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;  &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2013/01/php-api-documentation.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-hgkTm_lJXNo/UPTuxXYuhHI/AAAAAAAABlg/exwYih6JlKA/s72-c/apigen.org.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-1964219266530664878</guid><pubDate>Wed, 26 Dec 2012 05:19:00 +0000</pubDate><atom:updated>2012-12-25T21:19:25.328-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.htaccess</category><category domain="http://www.blogger.com/atom/ns#">mod_rewrite services</category><category domain="http://www.blogger.com/atom/ns#">PHP</category><title>PHP : mod_rewrite services</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Experience working with PHP is really good. But really missed the way rails for handling urls dynamically. &lt;br /&gt;Really feeling nice when I found the way to add such method for dynamic urls. &lt;br /&gt;Just need to use mod_rewrite in .htaccess file for the respective project. &lt;br /&gt;&lt;br /&gt;In the beginning didn&#39;t work as per the requirement.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-3cN1rK4QIfo/UNfwKY8AfDI/AAAAAAAABTk/-TEb01viLkM/s1600/404_no_url.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;427&quot; src=&quot;http://3.bp.blogspot.com/-3cN1rK4QIfo/UNfwKY8AfDI/AAAAAAAABTk/-TEb01viLkM/s640/404_no_url.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;After some research found the post &lt;a href=&quot;http://www.ghacks.net/2009/12/05/enable-mod_rewrite-in-a-ubuntu-server/&quot; target=&quot;blank&quot;&gt;enable-mod_rewrite-in-a-ubuntu-server&lt;/a&gt; which helped a lot for starting the mod_rewrite services.&lt;br /&gt;&lt;br /&gt;By default it showed that mod_rewrite services are running but need some changes in the files which are as below.&lt;br /&gt;&lt;br /&gt;Just need to run &lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;sudo gedit /etc/apache2/sites-enabled/000-default&lt;br /&gt;&lt;/pre&gt;and in &lt;i&gt;&amp;lt;Directory /&amp;gt;&lt;/i&gt; and &amp;lt;Directory /var/www/&amp;gt; section change &lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;AllowOverride None&lt;br /&gt;&lt;/pre&gt;to &lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;AllowOverride All&lt;br /&gt;&lt;/pre&gt;And then just &lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;sudo /etc/init.d/apache2 restart&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-Z15gEW8I6xQ/UNfwm4dNl_I/AAAAAAAABTw/ymc7n7bZ2o8/s1600/url_found.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;440&quot; src=&quot;http://2.bp.blogspot.com/-Z15gEW8I6xQ/UNfwm4dNl_I/AAAAAAAABTw/ymc7n7bZ2o8/s640/url_found.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;  &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2012/12/php-modrewrite-services.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-3cN1rK4QIfo/UNfwKY8AfDI/AAAAAAAABTk/-TEb01viLkM/s72-c/404_no_url.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-2223114575012738448</guid><pubDate>Fri, 23 Nov 2012 08:27:00 +0000</pubDate><atom:updated>2012-12-31T04:45:05.297-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Collection</category><category domain="http://www.blogger.com/atom/ns#">Collection : PHP</category><category domain="http://www.blogger.com/atom/ns#">PHP</category><title>Collection : PHP : Insert Data Function</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;In my previous post we added select_tag function for views as a helper function. Now we will add some function for inserting record. The names of functions might be similar to rails methods. This becomes easy for me to keep it simple to remember.&lt;br /&gt;&lt;br /&gt;Lets consider we have some products table with id, name and description columns. As I have kept id auto generated we will not add if field in form.&lt;br /&gt;&lt;br /&gt;In new.php&lt;br /&gt;&lt;div class=&quot;html4strict&quot; style=&quot;background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/form.html&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;form&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;product&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;method&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;POST&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;action&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;create.php&quot;&lt;/span&gt; &amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/input.html&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;input&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;product[name]&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/textarea.html&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;textarea&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rows&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;6&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;product[description]&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/textarea.html&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;textarea&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/input.html&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;input&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;product_submit&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;button&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Save&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;submit();&quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/form.html&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;form&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-c6k1c508SGA/UK8liW3PFsI/AAAAAAAABTM/1sqh0_ojdt4/s1600/form.png&quot; imageanchor=&quot;1&quot;&gt;Check View&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Now when you click on save button it should redirect you to create.php.&amp;nbsp;For now just add&lt;br /&gt;&lt;div class=&quot;php&quot; style=&quot;background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/print_r&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;print_r&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;and you can see (in view) &lt;a href=&quot;http://3.bp.blogspot.com/-1-i0bbU8CI0/UK8leEydWhI/AAAAAAAABTA/SS6AKrIX0ZM/s1600/create_array.png&quot; imageanchor=&quot;1&quot;&gt;Check View&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;If you need to validate the records you can just add some code before the function we are going to add.&lt;br /&gt;But I will just keep it simple, so directly going to add it to the database.&lt;br /&gt;&lt;br /&gt;In create.php&lt;br /&gt;&lt;div class=&quot;php&quot; style=&quot;background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;require_once&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;includes/php/active_queries.php&#39;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;insert_record&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;product&#39;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;products&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;a href=&quot;http://www.php.net/header&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;header&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;Location: index.php&#39;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;I have added active_queries.php, with this we will insert the data in table.&lt;br /&gt;&lt;div class=&quot;php&quot; style=&quot;background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp;* For Inserting a single record&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp;* @param array $record &amp;lt;p&amp;gt;Array of single record&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp;* @param string $model &amp;lt;p&amp;gt;Table name in which you want to make changes&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;function&lt;/span&gt; insert_record&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$record&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$model&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$fields&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/count&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;count&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$record&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$fields&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$i&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$k&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$insert&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;INSERT INTO &quot;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$model&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot; (&quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$record&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$key&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$k&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;++;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$insert&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$key&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$fields&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$k&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$insert&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;, &quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$insert&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;) VALUES (&quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$record&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$key&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;++;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.php.net/gettype&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;gettype&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;string&#39;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$insert&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot; &#39;&quot;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;a href=&quot;http://www.php.net/pg_escape_string&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;pg_escape_string&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;&#39;&quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$insert&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$value&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$fields&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$insert&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;, &quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$insert&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;)&quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$result&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/pg_query&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;pg_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$insert&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;a href=&quot;http://www.php.net/pg_affected_rows&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;pg_affected_rows&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;This function will run loop of array twice. First to get the keys and then the values. And then it will add the data to the database. Once the query runs successfully it will return to the index page as we have mentioned header location as index.php. And you can see the inserted records.&lt;br /&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-Pc8GZspAvAo/UK8lYPkdYsI/AAAAAAAABS0/JjRC77oUHko/s1600/form1.png&quot; imageanchor=&quot;1&quot;&gt;Check Form View&lt;/a&gt; and &lt;a href=&quot;http://2.bp.blogspot.com/-aoAJ7bU1RpE/UK8lTKXIZvI/AAAAAAAABSo/AHmBrkl1C-A/s1600/all.png&quot; imageanchor=&quot;1&quot;&gt;Check Index View&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Now what if we want to add multiple records in one form/ click. This is not required for now but this can be used in nested_attributes.&lt;br /&gt;&lt;br /&gt;So I added multiple_products.php in which we will add multiple fields.&lt;br /&gt;&lt;div class=&quot;php&quot; style=&quot;background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;lt;form id=&quot;products&quot; method=&quot;POST&quot; action=&quot;create.php&quot; &amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;lt;input name=&quot;multiple&quot; type=&quot;hidden&quot; value=&quot;true&quot; /&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;i&amp;gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$i&lt;/span&gt; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;. Name :&amp;lt;/i&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;input name=&quot;products[&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$i&lt;/span&gt; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;][name]&quot; type=&quot;text&quot; value=&quot;&quot; /&amp;gt; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;i&amp;gt;Description :&amp;lt;/i&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;textarea rows=&quot;6&quot; name=&quot;products[&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$i&lt;/span&gt; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;][description]&quot;&amp;gt; &amp;lt;/textarea&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;lt;input id=&quot;product_submit&quot; type=&quot;button&quot; value=&quot;Save&quot; onclick=&quot;submit();&quot; /&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;lt;/form&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-FXkkbFVCKVg/UK8lOdvrPyI/AAAAAAAABSc/PgZ4rW5Hdio/s1600/multiple_products.png&quot; imageanchor=&quot;1&quot;&gt;Check View&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;We are not creating another php file to submit these products to database. We will use the same create.php for which I added hidden field as multiple=true&lt;br /&gt;&lt;br /&gt;In active_queries.php&lt;br /&gt;&lt;div class=&quot;php&quot; style=&quot;background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp;* For Inserting multiple records&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp;* @param array $records &amp;lt;p&amp;gt;Array of records&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp;* @param string $model &amp;lt;p&amp;gt;Table name in which you want to make changes&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;function&lt;/span&gt; insert_multiple_records&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$records&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$model&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$records&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$record&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &amp;nbsp; insert_record&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$record&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$model&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;And in create.php need to change some code. Instead of&lt;br /&gt;&lt;div class=&quot;php&quot; style=&quot;background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;insert_record&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;product&#39;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;products&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;change code to&lt;br /&gt;&lt;div class=&quot;php&quot; style=&quot;background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.php.net/isset&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;isset&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;multiple&#39;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; insert_multiple_records&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;products&#39;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;products&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 80% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&amp;nbsp; insert_record&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;product&#39;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;products&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #006060; font-weight: bold; font-weight: bold; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; color: #000020; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-xX1pO_-O-IY/UK8kuw1qVRI/AAAAAAAABSE/ht1_E-CXpyE/s1600/create_multiple_array.png&quot; imageanchor=&quot;1&quot;&gt;Check View&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;This will just get all data in and will run in loop which will call previous function(insert_record()) for each record array.&lt;br /&gt;&lt;br /&gt;So after redirecting to index page we can view the inserted to reqords .&amp;nbsp;&lt;a href=&quot;http://1.bp.blogspot.com/-tnFIPLgENU8/UK8lFC0PzaI/AAAAAAAABSQ/GSM10DUllDU/s1600/all1.png&quot; imageanchor=&quot;1&quot;&gt;Check View&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;You can download whole source from &lt;a href=&quot;https://github.com/supriyassurve/php_example_projects&quot; target=&quot;_blank&quot;&gt;github&lt;/a&gt;&lt;/div&gt;</description><link>http://blog.supriyasurve.com/2012/11/collection-php-insert-data-function.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-4989149844604674140</guid><pubDate>Tue, 20 Nov 2012 05:28:00 +0000</pubDate><atom:updated>2012-12-31T04:45:27.660-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Collection</category><category domain="http://www.blogger.com/atom/ns#">Collection : PHP</category><category domain="http://www.blogger.com/atom/ns#">PHP</category><title>Collection : PHP : select_tag</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Learning PHP is fun to me but really miss the available helpers in Rails. &lt;br /&gt;For example form helpers like form/ select_tag/ text_field and others.&lt;br /&gt;&lt;br /&gt;I dont know whether these are already available in php or not. &lt;br /&gt;So I added one file as common_helper.php and that can be directly required or  just added separate (module_name)_helper.php and require common_helper.php in  the new file. I have added module wise view helpers, so that I can keep the common  helper functions and module wise helper function separate from each other.&lt;br /&gt;&lt;br /&gt;This function creates a HTML select with options and selected option. Parameters required are : &lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;i&gt;$name as&lt;/i&gt; string (Name for select node).&lt;/li&gt;&lt;li&gt;&lt;i&gt;$options&lt;/i&gt; as array (Array for generating options).&lt;/li&gt;&lt;li&gt;&lt;i&gt;$selected&lt;/i&gt; as string or integer - optional - (Selected value or blank string).&lt;/li&gt;&lt;li&gt;&lt;i&gt;$css_class&lt;/i&gt; as string - optional - (Css class name(s)).&lt;/li&gt;&lt;li&gt;&lt;i&gt;$onchange&lt;/i&gt; as string - optional - (onchange functionality)&lt;/li&gt;&lt;/ol&gt;This will append the given name and class name to select tag. Selected value will be selected in options by comapering the $selected.&lt;br /&gt;Options send to the helper function needs to be array. &lt;br /&gt;For example: &lt;br /&gt;1. array(1, 2, 3, 4, 5, 6, 7);&lt;br /&gt;Or&lt;br /&gt;2. array(array(0,&quot;0 Hours&quot;), array(1,&quot;1 Hour&quot;), array(2,&quot;2 Hours&quot;), array(3, &quot;3 Hours&quot;), array(4, &quot;4 Hours&quot;)); &lt;br /&gt;Still for making work this code you will need to pass first 2 mandatory parameters which are name and array of options which will create the option tags for select_tag.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;php&quot; style=&quot;background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp;  &lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;/** &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * Creates a HTML select with options and selected option.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * @param string $name &amp;lt;p&amp;gt;Name for select node&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * @param array $options &amp;lt;p&amp;gt;Array for generating options&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * @param string $selected &amp;lt;p&amp;gt;Selected value or blank string. Can be string or integer.&amp;lt;/p&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * @param string $css_class &amp;lt;p&amp;gt;Css class name(s) as a string&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * &amp;lt;p&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * This will append the given name and class name to select tag.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * Selected value will be selected in options by comapering the $selected.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * Options send to the helper function needs to be array&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * For example:&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * 1. array(1, 2, 3, 4, 5, 6, 7);&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * Or&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * 2. array(array(0,&quot;0 Hours&quot;), array(1,&quot;1 Hour&quot;), array(2,&quot;2 Hours&quot;), array(3, &quot;3 Hours&quot;), array(4, &quot;4 Hours&quot;));&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; * &amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;function&lt;/span&gt; select_tag&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$name&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$options&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$selected&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$css_class&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$onchange&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$select_tag&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;&amp;lt;select class=&quot;&#39;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$css_class&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;&quot; name=&quot;&#39;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$name&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$onchange&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$select_tag&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;&quot; onchange=&quot;&#39;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$onchange&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$select_tag&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;&quot;&amp;gt;&#39;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$select_options&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;foreach&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$options&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$a&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.php.net/is_array&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;is_array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$a&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$ky&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$a&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$val&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$a&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$ky&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$a&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$val&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$a&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$select_options&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;&amp;lt;option value=&quot;&#39;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$ky&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;&quot;&#39;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$selected&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$ky&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;{&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$select_options&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39; selected=&quot;selected&quot;&#39;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$select_options&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;&amp;gt;&#39;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$val&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;&amp;lt;/option&amp;gt;&#39;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000088;&quot;&gt;$select_tag&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$select_options&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&#39;&amp;lt;/select&amp;gt;&#39;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$select_tag&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;color: #003030; font-weight: small; font: small small 100% &#39;Courier New&#39;, Courier, monospace; vertical-align: top;&quot;&gt;&lt;div style=&quot;background: none; font: small small 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top; white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;So now in view we can directly add in php tag &lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;php&quot; style=&quot;font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: small; vertical-align:top;font: small small 100% &#39;Courier New&#39;, Courier, monospace; color: #003030;&quot;&gt;&lt;div style=&quot;font: small small 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;;white-space: nowrapcolor: #000020;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;echo&lt;/span&gt; select_tag&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;select_name&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;a style=&quot;color: #000060;&quot; href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$selected_value&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;classname&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;onchange_javascript_function(this.value);&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;In the project I am working on needed the onchange javascript function. &lt;br /&gt;Its not mandatory. So you can just avoid or remove that from the code.&lt;br /&gt;&lt;br /&gt;This code is available on github : &lt;a href=&quot;https://github.com/supriyassurve/php_common_helpers.git&quot; target=&quot;_blank&quot;&gt;php_common_helpers.git&lt;/a&gt;. &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2012/11/collection-php-selecttag.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-4963199927352901561</guid><pubDate>Fri, 16 Nov 2012 11:35:00 +0000</pubDate><atom:updated>2012-12-31T04:46:18.645-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Collection</category><category domain="http://www.blogger.com/atom/ns#">Collection : Javascript</category><category domain="http://www.blogger.com/atom/ns#">javascript</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Collection : Javascript : Validating max length</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;There are some scripts/ functionalities which are commonly and mostly used in many web based applications. I would like to keep some in the collection with us. These might be simple for the readers but are very important to make a note of it. &lt;br /&gt;&lt;br /&gt;In this post I will keep note of 1 javascript function which restricts the user by adding more than the specific limit for the input. Or validating the input for certain limit to enter.&lt;br /&gt;&lt;br /&gt;In Javascript file &lt;br /&gt;&lt;pre class=&quot;brush:jscript&quot;&gt;/* check_the_max_length(input, maxLen) &lt;br /&gt;  input  : need a id or class of input&lt;br /&gt;  maxLen : IE do not accept maxlength so passing it as a parameter.&lt;br /&gt;*/&lt;br /&gt;function check_the_max_length(input, maxLen){&lt;br /&gt;  var val = $(input).val();&lt;br /&gt;  var left = maxLen - val.length;&lt;br /&gt;  var remaining_points = left&amp;lt;=0 ? 0 : left&lt;br /&gt;  $(&#39;#counter&#39;).html(remaining_points + &#39;/&#39; + maxLen);&lt;br /&gt;  if (val.length &amp;gt;= maxLen) {&lt;br /&gt;      $(input).val(val.slice(0, maxLen));&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Considering in view &lt;pre class=&quot;brush:ruby&quot;&gt;&lt;br /&gt;&lt;%= f.input :description, :as =&gt; :text, :input_html =&gt; {:style =&gt; &quot;width:450px;&quot;}&lt;br /&gt;&lt;div id=&#39;counter&#39;&gt;&lt;/div&gt;&lt;br /&gt;&lt;/pre&gt; I added some javascript in views, as application&#39;s most of the views are on popups. In main view, where popups will get displayed, add following lines at bottom in script tag. &lt;br /&gt;&lt;pre class=&quot;brush:jscript&quot;&gt;$(&#39;#description&#39;).live(&#39;keyup keydpress&#39;, function(e) {&lt;br /&gt;  check_the_max_length(&#39;#description&#39;, 220);&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;As we read, for IE, maxlength was not working, there was another bug. while entering paragraphs it do no calculate properly. For example: if I enter 4 paras the count will show I still have 4 values to enter. But max length attribute actually do not let you enter the value. So removed the maxlength attribute from views for inputs and added slice method which will actually cut down the text to original required count. SO the above function is the solution for both bugs.  &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2012/11/collection-javascript-validating-max.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-7544073168538872332</guid><pubDate>Mon, 05 Nov 2012 08:40:00 +0000</pubDate><atom:updated>2012-11-05T00:40:43.391-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Postgres</category><title>Postgres : Server Installation and settings</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Postgres is one of the popular database server for Ruby on Rails Applications. This post takes us step by step, installation and some important settings. &lt;br /&gt;&lt;br /&gt;Postgres 9.1.x installation steps&lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;sudo add-apt-repository ppa:pitti/postgresql&lt;br /&gt;sudo apt-get update&lt;br /&gt;sudo apt-get install postgresql&lt;br /&gt;&lt;/pre&gt;This will install the postgresql to the server/ your local machine. If you just want to use it locally then these steps are enough. But if you also want to use this database available for other machines then you have to add the ip to pg_hba.conf for making availablity for that ip machine only.&lt;br /&gt;There is also other option for making database available if your ip is not stable. which is as given below. But also suggested use this only if server is only for internal use. For this we need to make following changes in&lt;br /&gt;&lt;br /&gt;&lt;b&gt;/etc/postgresql/9.1/main/pg_hba.conf&lt;/b&gt;(find following and make changes as shown) &lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;# TYPE  DATABASE     USER  ADDRESS        METHOD&lt;br /&gt;  local all          all                  trust&lt;br /&gt;  host  all          all   127.0.0.1/32   trust&lt;br /&gt;&lt;/pre&gt;And another to the same file&lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;# IPv4 local connections:&lt;br /&gt;&lt;br /&gt;# host  all          all   127.0.0.1/32   md5&lt;br /&gt;  host  all          all   0.0.0.0/0      trust&lt;br /&gt;&lt;/pre&gt;other file to make changes is &lt;b&gt;/etc/postgresql/9.1/main/postgresql.conf&lt;/b&gt;&lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;port = 5432&lt;br /&gt;listen_addresses = &#39;*&#39;&lt;br /&gt;&lt;/pre&gt;And then just restart the server.&lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;sudo /etc/init.d/postgresql restart&lt;br /&gt;&lt;/pre&gt;Install pgAdmin3&lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;sudo apt-add-repository ppa:flexiondotorg/postgres&lt;br /&gt;sudo apt-get update&lt;br /&gt;sudo apt-get install pgadmin3&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;</description><link>http://blog.supriyasurve.com/2012/11/postgres-server-installation-and.html</link><author>noreply@blogger.com (Supriya Surve)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-5912511949906484426</guid><pubDate>Thu, 25 Oct 2012 06:20:00 +0000</pubDate><atom:updated>2012-10-24T23:20:23.757-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">abd</category><category domain="http://www.blogger.com/atom/ns#">Android</category><category domain="http://www.blogger.com/atom/ns#">Phonegap</category><title>Phonegap : adb command not found</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;As many people must have known that &lt;a href=&quot;http://phonegap.com/&quot; target=&quot;_blank&quot;&gt;Phonegap&lt;/a&gt; is really nice for cross platform mobile app development. I installed android development environment via eclipse and &lt;a href=&quot;http://phonegap.com/download&quot; target=&quot;_blank&quot;&gt;downloaded the latest plugin of phonegap&lt;/a&gt;.  &lt;br /&gt;&lt;br /&gt;Tried out the sample application given in the plugin. It worked well in emulator but while running it on my sony ericsson x10i I faced some problems as I will say I am new to android development. &lt;br /&gt;&lt;br /&gt;First my phone was not recognized by Android device chooser in eclipse. So I got that I will have to add rules file to users/udev/something folder. So I followed the &lt;a href=&quot;http://dimitar.me/how-to-connect-your-android-phone-to-ubuntu-to-do-developmenttestinginstallations-or-tethering/&quot; target=&quot;_blank&quot;&gt;dimitar.me&lt;/a&gt;. Also the information is given on &lt;a href=&quot;http://developer.android.com/tools/device.html#setting-up&quot; tagret=&quot;_blank&quot;&gt;developer.android.com&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Even for sony need to add  sudo gedit /etc/udev/rules.d/51-android.rules  and the required information in the file. &lt;br /&gt;&lt;br /&gt;Now when I completed most of the steps command  &lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;adb devices&lt;/pre&gt;was not getting the output. But instead throwing the error as below. &lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-HRlu-rza88g/UIjZy4OCwUI/AAAAAAAABRc/CGzQKRM4-08/s1600/command+not+found.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;234&quot; src=&quot;http://3.bp.blogspot.com/-HRlu-rza88g/UIjZy4OCwUI/AAAAAAAABRc/CGzQKRM4-08/s320/command+not+found.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Changed the permissions for the same file. I again run the adb command, but no positive result still the same in terminal and in eclipse. Finally restarted the pc and checked the command in terminal. Still the same error. But when I checked it in eclipse it showed the device chooser. &lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-EOwLcA_FEGk/UIjZ5F6RlhI/AAAAAAAABRk/DHpEWcVBW0M/s1600/device_chooser.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;http://1.bp.blogspot.com/-EOwLcA_FEGk/UIjZ5F6RlhI/AAAAAAAABRk/DHpEWcVBW0M/s320/device_chooser.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Thats it and the device detected and apk installed successfully. &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2012/10/phonegap-adb-command-not-found.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-HRlu-rza88g/UIjZy4OCwUI/AAAAAAAABRc/CGzQKRM4-08/s72-c/command+not+found.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7702816563349321195.post-4365714103860395370</guid><pubDate>Thu, 13 Sep 2012 10:02:00 +0000</pubDate><atom:updated>2012-09-13T03:02:03.098-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PHP</category><category domain="http://www.blogger.com/atom/ns#">phpmyadmin</category><title>PHP : phpmyadmin not found</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Recently I installed php on my pc. But got some trouble when I installed phpmyadmin and tried to view it in browser. It displayed as Not Found.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-gu5KnsnPR78/UFGtirz0LQI/AAAAAAAABP8/oUCwBvoCgoY/s1600/not_found.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;201&quot; src=&quot;http://2.bp.blogspot.com/-gu5KnsnPR78/UFGtirz0LQI/AAAAAAAABP8/oUCwBvoCgoY/s400/not_found.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;But after some research found that I will have to move the phpmyadmin folder from usr/share location to var/www &lt;br /&gt;So I run the below command from terminal &lt;br /&gt;&lt;pre class=&quot;brush:ruby&quot;&gt;sudo mv /usr/share/phpmyadmin /var/www/phpmyadmin&lt;/pre&gt;And phpmyadmin was running as required in browser. &lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-QEsmhLhCAXw/UFGuadAQj5I/AAAAAAAABQI/eWVGplyJYqs/s1600/found.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;265&quot; src=&quot;http://1.bp.blogspot.com/-QEsmhLhCAXw/UFGuadAQj5I/AAAAAAAABQI/eWVGplyJYqs/s400/found.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;   &lt;/div&gt;</description><link>http://blog.supriyasurve.com/2012/09/php-phpmyadmin-not-found.html</link><author>noreply@blogger.com (Supriya Surve)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-gu5KnsnPR78/UFGtirz0LQI/AAAAAAAABP8/oUCwBvoCgoY/s72-c/not_found.png" height="72" width="72"/><thr:total>0</thr:total></item></channel></rss>