tag:blogger.com,1999:blog-31343174345900957502023-11-15T07:31:19.203-08:00PHP TUTORIALS FOR WEB DEVELOPERS - PHP ROCKERSPHP Developers, Coding, Tutorials, DevelopmentsRamhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.comBlogger79125tag:blogger.com,1999:blog-3134317434590095750.post-24597199229148289022012-08-08T02:35:00.000-07:002012-08-08T02:35:10.374-07:00Display the custom file in cms block to frontend/backend in Magento<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">Below coding can be used to show CMS block in Frontend.</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
Ref. Path : app/design/frontend/base/default/template/callouts/left_col.phtml or right_col.phtml.</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_id')->toHtml(); ?></span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">Setting in Backend:</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">First Go to CMS and create a static page. Here we take "identifier" id from static block and put this id to above coding inside setBlock_id. And inside content we have put following line for calling our own block coding file,</span></div><div style="font-family: Times,"Times New Roman",serif;"><br />
</div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">{{block type="core/template" name="leftnav_menu" template="menu/menu.phtml"}}</span></div><div style="font-family: Times,"Times New Roman",serif;"><br />
</div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">Finally we have saved the file and this file is running in frontend inside the block. </span></div><div style="font-family: Times,"Times New Roman",serif;"><br />
</div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-21575521164473972182012-07-30T03:14:00.000-07:002012-07-30T03:14:52.058-07:00Database connection in Joomla 2.5<div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: justify;"><pre class="de1" style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><span class="re0">We have easy to connect database in joomla 2.5. Using below function</span></span></pre><pre class="de1" style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><span class="re0">we have to connect database wherever you want in joomla folder.</span></span></pre><pre class="de1" style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><span class="re0"> </span></span></pre><pre class="de1" style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><span class="re0">$db</span> <span class="sy0">=&</span> JFactory<span class="sy0">::</span><span class="me2">getDBO</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span>
</span></pre><pre class="de1" style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><span class="kw1"></span><span class="sy0"></span></span></pre></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-44808760375662192692012-06-20T05:12:00.000-07:002012-06-20T05:12:54.503-07:00What is MVC in Joomla?<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">MVC - <span class="a" style="left: 2112px; letter-spacing: -1px; top: 2982px;">Model-View-Component</span></span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><span class="a" style="left: 663px; top: 3592px; word-spacing: -1px;">“MVC consists of three kinds of objects. The Model is the <span class="w6"></span>application object, the View is</span><span class="a" style="left: 663px; top: 3694px; word-spacing: -1px;">its screen presentation, and the Controller defines the <span class="w6"></span>way that the user interface reacts to</span><span class="a" style="left: 663px; top: 3795px; word-spacing: -1px;">the user input.</span></span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com1tag:blogger.com,1999:blog-3134317434590095750.post-41370301836128840732012-05-30T10:45:00.002-07:002012-05-30T10:45:40.054-07:00Create a custom page template in wordpress<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">we have a sidebar on all of pages in wordpress website, but we want to have a page that doesn’t have a sidebar. Here is how we create a custom page template without a sidebar in wordpress:<br />
<br />
1) Create a new file in wordpress theme folder and name it withoutSidebar.php.<br />
<br />
2) Open page.php and copy all of the code and paste it into the newly created withoutSidebar.php.<br />
<br />
3) Make any changes that you would like to withoutSidebar.php. In this example we are going to remove the sidebar, so find the code that calls the sidebar (<?php include(‘sidebar.php’); ?>) and remove it.<br />
<br />
4) You may also want to find the div that contains the main container and add a width style to make it cover the whole page.<br />
<br />
5) Finally, and most importantly, add the following line of code to the top of the page. This code is used to tell WordPress that this is a custom template. Without this code, WordPress would not be able to find the template:<br />
<br />
<br />
<?php<br />
/*<br />
Template Name: without Sidebar<br />
*/<br />
?><br />
<br />
6) Save this file and upload it to your server.</span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-70706973371140008072012-03-28T06:24:00.002-07:002012-03-28T06:27:04.018-07:00Difference between Primary Key and Unique key in mysql?<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">Difference between Primary Key and Unique key in mysql/sql/oracle?</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><table border="1" style="font-family: Times,"Times New Roman",serif;"><tbody>
<tr> <th><span style="font-size: large;">SNO </span></th> <th><span style="font-size: large;">Primary Key</span></th> <th><span style="font-size: large;">Unique Key</span></th> </tr>
<tr> <td><span style="font-size: large;">1</span></td> <td><span style="font-size: large;">Primary Key does not allow NULLs values in a table</span></td> <td><span style="font-size: large;">Unique Key allows Nulls value in a table</span></td> </tr>
<tr> <td><span style="font-size: large;">2</span></td> <td><span style="font-size: large;">Only one primary key will be there in a table</span></td> <td><span style="font-size: large;">More than one unique key will be there in a table</span></td> </tr>
<tr> <td><span style="font-size: large;">3</span></td> <td><span style="font-size: large;">Clustered index is created in primary key in a table</span></td> <td><span style="font-size: large;">Non-Clustered index is created in unique key in a table</span></td> </tr>
<tr> <td><span style="font-size: large;">4</span></td> <td><span style="font-size: large;">Primary key allows each row in a table to be uniquely identified and ensures that no duplicate rows exist as well as does not allow the duplicates values in the rows of a table.</span></td> <td><span style="font-size: large;">Unique key constraint is used to prevent the duplication of key values within the rows of a table and allow null values</span></td> </tr>
</tbody></table><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">By default Primary Key creates a Clustered Index on the column as same as Unique Key creates a Nonclustered Index. Another major difference is Primary Key doesn’t allow NULLs, but Unique Key allows NULLs. We can create only one primary key in a table, but a table can have the multiple unique key.</span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-59441888415730846892012-03-27T02:44:00.000-07:002012-03-27T02:44:13.637-07:00Update query in mysql<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: large;"><span style="font-family: Times,"Times New Roman",serif;">The syntax for Update the row into tables,</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">UPDATE</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> table_name SET (colname1, colname2, colname3 ...) VALUES (value1,value2,value3,...) WHERE colname = row_values; </span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"><?php</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">$con = mysql_connect('localhost', 'root','');</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">mysql_select_db('dbname', $con) or die(mysql_error());</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">$query = "UPDATE table_name SET rank="2" WHERE sno = 2"; </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">$ok = mysql_query($query);</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">if($ok) </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">echo "Updated row successfully";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">else</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">echo "Failed to update the row in the table";</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">?></span></span><br />
<br />
<table border="1"><tbody>
<tr> <th>sno</th> <th>name</th> <th>marks</th> <th>rank</th> <th>post_of_date</th> </tr>
<tr> <td>2</td> <td>krishnan</td> <td>397</td> <td>2</td> <td>09-04-2001</td> </tr>
<tr> <td>3</td> <td>PHP Developer</td> <td>521</td> <td>36</td> <td>27-03-2012</td> </tr>
</tbody></table></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-84977370478756934592012-03-27T02:37:00.000-07:002012-03-27T02:37:17.808-07:00Delete query in mysql with php<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: large;"><span style="font-family: Times,"Times New Roman",serif;">The syntax for Delete the row into tables,</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">DELETE FROM </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> table_name WHERE colname = row_values; </span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"><?php</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">$con = mysql_connect('localhost', 'root','');</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">mysql_select_db('dbname', $con) or die(mysql_error());</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">$query = "DELETE FROM table_name WHERE sno = 1"; </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">$ok = mysql_query($query);</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">if($ok) </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">echo "Deleted row successfully";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">else</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">echo "Failed to delete the row in the table";</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">?></span></span><br />
<br />
<br />
<table border="1"><tbody>
<tr> <th>sno</th> <th>name</th> <th>marks</th> <th>rank</th> <th>post_of_date</th> </tr>
<tr> <td>2</td> <td>krishnan</td> <td>397</td> <td>3</td> <td>09-04-2001</td> </tr>
<tr> <td>3</td> <td>PHP Developer</td> <td>521</td> <td>36</td> <td>27-03-2012</td> </tr>
</tbody></table></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-50754591732660859932012-03-27T02:22:00.002-07:002012-03-27T02:31:52.260-07:00Insert query in mysql with php<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: large;"><span style="font-family: Times,"Times New Roman",serif;">The syntax for inserting values into tables,</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">INSERT INTO </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> table_name (`col1`, `col2`, `col3`,.....) </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> VALUES ('val1', 'val2', 'val3',.....); </span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"><?php</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">$con = mysql_connect('localhost', 'root','');</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">mysql_select_db('dbname', $con) or die(mysql_error());</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">$query = "INSERT INTO table_name (`sno`, `name`, `marks`, `rank`,`post_of_date`) VALUES ('3', 'PHP Developer', '521', '36',now())"; </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">$ok = mysql_query($query);</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">if($ok) </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">echo "Inserted successfully";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">else</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">echo "Data's are not inserted in to table";</span><br style="font-family: Times,"Times New Roman",serif;" /><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">?></span></span><br />
<br />
<br />
<table border="1"><tbody>
<tr> <th>sno</th> <th>name</th> <th>marks</th> <th>rank</th> <th>post_of_date</th> </tr>
<tr> <td>1</td> <td>Ram</td> <td>407</td> <td>3</td> <td>09-04-2001</td> </tr>
<tr> <td>2</td> <td>krishnan</td> <td>397</td> <td>3</td> <td>09-04-2001</td> </tr>
<tr> <td>3</td> <td>PHP Developer</td> <td>521</td> <td>36</td> <td>27-03-2012</td> </tr>
</tbody></table></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-33336209825853983702012-03-26T06:34:00.000-07:002012-03-26T06:34:02.295-07:00Show the content or text when mouse over the link<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"><style type="text/css"></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"><!--</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">.box {</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">background-color: #F4F4F4;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">border: 1px solid #CCC;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">height: 150px;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">width: 225px;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">padding: 5px;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">display:none;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">position:absolute;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">}</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"><br />
</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">--></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"></style></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"><script type="text/javascript" language="JavaScript"></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">var cX = 0; var cY = 0; var rX = 0; var rY = 0;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">else { document.onmousemove = UpdateCursorPosition; }</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">function AssignPosition(d) {</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">if(self.pageYOffset) {</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">rX = self.pageXOffset;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">rY = self.pageYOffset;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">}</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">else if(document.documentElement && document.documentElement.scrollTop) {</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">rX = document.documentElement.scrollLeft;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">rY = document.documentElement.scrollTop;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">}</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">else if(document.body) {</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">rX = document.body.scrollLeft;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">rY = document.body.scrollTop;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">}</span><br />
<a name='more'></a><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">if(document.all) {</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">cX += rX;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">cY += rY;</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">}</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">d.style.left = (cX-50) + "px";</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">d.style.top = (cY-170) + "px";</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">}</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">function HideText(d) {</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">if(d.length < 1) { return; }</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">document.getElementById(d).style.display = "none";</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">}</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">function ShowText(d) {</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">if(d.length < 1) { return; }</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">var dd = document.getElementById(d);</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">AssignPosition(dd);</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">dd.style.display = "block";</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">}</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">function ReverseContentDisplay(d) {</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">if(d.length < 1) { return; }</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">var dd = document.getElementById(d);</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">AssignPosition(dd);</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">if(dd.style.display == "none") { dd.style.display = "block"; }</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">else { dd.style.display = "none"; }</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">}</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">//--></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"></script></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"><br />
</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"><br />
</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"><span</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">onmouseover="ShowText('Message'); return true;"</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">onmouseout="HideText('Message'); return true;"</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">href="javascript:ShowText('Message')"></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">Contact Us</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"></span></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"><div</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">id="Message"</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">class="box"</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">Ramakrishnan V.<br/></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">14,Robinson Park Colony,<br/></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">M.C. Road,<br/></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">Old Washermenpet,<br/></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">Chennai-600 021.<br/></span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;">Contact No: 9445094568.</span><br />
<span style="font-family: Times, 'Times New Roman', serif; font-size: large;"></div> </span><br />
</div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-46816609087608196872012-03-21T07:39:00.002-07:002012-03-21T07:41:15.495-07:00How to delete checked checkbox rows in php?<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><?php<br />
if($_REQUEST['btndelete'] != '')<br />
{<br />
if(!<span style="color: red;">empty($_REQUEST['checkboxstatus'])</span>) {<br />
$checked_values = $_REQUEST['checkboxstatus'];<br />
foreach($checked_values as $val) {<br />
$sqldel = "delete from subscribe where id = '$val'";<br />
$resdel = mysql_query($sqldel);<br />
if($resdel) <br />
$error_log = 1;<br />
else <br />
$error_log = 2;<br />
}<br />
}<br />
}</span></div><a name='more'></a><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
$openingcountry = $_REQUEST['openingcountry'];<br />
if($_REQUEST['status'] != '') {<br />
$status = $_REQUEST['status'];<br />
}<br />
?><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<body><br />
<form name="frmcountry" method="post" action=""><br />
<table align="center" cellpadding="0" cellspacing="0" border="0" width="100%"><br />
<tr><br />
<td><br />
<input type="submit" name="btndelete" value="DELETE" class="openlistdelete" onClick="javascript: return confirm('Are you sure you want to delete!')" /><br />
<div style="color:#FF0000;"><br />
<?php <br />
if($error_log == 2) <br />
echo "Selected email id is not deleted";<br />
if($error_log == 1) <br />
echo "Deleted successfully";<br />
<br />
?><br />
</div><br />
</td><br />
</tr><br />
<tr><br />
<td class="openingtitletxt">S.No. </td><br />
<td class="openingtitletxt">Email </td><br />
<br />
<td class="openingtitletxt">Country </td><br />
<td class="openingtitletxt">Statu </td><br />
<td class="openingtitletxt">Edit Status </td><br />
</tr><br />
<?<br />
$rest = '';<br />
<br />
if($openingcountry != "") {<br />
$rest .= "where country = '$openingcountry'";<br />
}<br />
if($status!='') { <br />
if($openingcountry != "")<br />
$rest.= " and status = '$status'";<br />
else <br />
$rest.= "where status = '$status'";<br />
} <br />
$sqlselopenings = "select * from subscribe ".$rest ."ORDER BY id desc";<br />
$resselopenings = mysql_query($sqlselopenings);<br />
if($resselopenings) {<br />
$numrowsopenings = mysql_num_rows($resselopenings);<br />
} <br />
<br />
if($numrowsopenings > 0) {<br />
$i = 1;<br />
while($rowselopenings = mysql_fetch_array($resselopenings)) {<br />
?><br />
<tr><br />
<td class="openingtitledetails"> <? echo $i;?></td><br />
<td class="openingtitledetails"><? echo $rowselopenings['email'];?></td><br />
<td class="openingtitledetails"><br />
<?if($rowselopenings['country'] == 'uk')<br />
echo $rowselopenings['country'] = 'UK';<br />
else if($rowselopenings['country'] == 'us')<br />
echo $rowselopenings['country'] = 'US';<br />
else <br />
echo $rowselopenings['country'] = ucfirst($rowselopenings['country']);?><br />
</td><br />
<td class="openingtitledetails"><br />
<? <br />
if($rowselopenings['status'] == 1) {<br />
echo 'Active';<br />
} else { <br />
echo 'Inactive';<br />
}<br />
?> <br />
</td><br />
<td class="openingtitledetails"><br />
<span style="color: red;"><input type="checkbox" name="checkboxstatus[<?php echo $i; ?>]" id="checkboxstatus-<?php echo $rowselopenings['id']; ?>" value="<?php echo $rowselopenings['id']; ?>" /> </span><br />
</td><br />
</tr><br />
<? $i++; <br />
}<br />
} else { ?><br />
<tr><br />
<td colspan="5" align="center" class="errortxt"> No Records Found! </td><br />
</tr> <br />
<? } ?><br />
</table><br />
</form> <br />
</body><br />
</html></span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-38087164058785576072012-03-08T02:50:00.000-08:002012-03-08T02:50:13.862-08:00How to send the email in php?<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: large;"><span style="font-family: Times,"Times New Roman",serif;">Easily send the email in php, you have to follow some steps </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"><?php</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $mail_to = "phprockers.blogspot@gmail.com";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $mail_subject = "Introducing New concept in PHP";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $body_content = "Hi <br/> We are introducing new method in php as well as we are teaching php clearly. Please click here and watch <a href='http://phprockers.blogspot.in/'>php tutorial</a>";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> if(mail($mail_to, $mail_subject, $body_content)){</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> echo "Email sent successfully";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> } else {</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> echo "Email sending problem. Please try again.";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> }</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;">?></span></span></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-30185443257410658742012-03-08T02:31:00.001-08:002012-03-08T02:32:20.057-08:00How to send the email with attachment in php?<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">Very simple to send the email with attachment with php validation.<br />
<br />
<span style="color: blue;">First we have to write html form for upload the attchement.</span><br />
<br />
<form name="uploadRes" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF'];" ><br />
<input type="file" name="resume" id="resume" /><br />
<input type="submit" name="res-submit" id="res-submit" value="Send Resume" /><br />
</form><br />
<br />
<span style="color: blue;">Validation for attaching the file. Here we have to find the file type, then send the email to particular function.</span></span><br />
</div><span style="font-size: large;"><span style="font-family: Times,"Times New Roman",serif;">if($_REQUEST['res-submit'] != '') {</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> if(!empty($_FILES)) { </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> function getExt($file) {</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $dot = strrpos($file, '.') + 1;</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> return substr($file, $dot);</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> }</span></span><br />
<br />
<a name='more'></a><span style="font-size: large;"><span style="font-family: Times,"Times New Roman",serif;"> $resume = $_FILES['resume']['name'];</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> if($resume != '')</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $resume = $resume;</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> else</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $resume = 'Not Uploaded!';</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $extension = getExt($resume);</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> if( $resume== 'Not Uploaded!')</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $error_flag = 1;</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> else {</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> if($extension != 'doc' || $extension != 'docx' || $extension != 'pdf' || $extension != 'odt' || $extension != 'txt') {</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $to = 'php.com';</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $from = "candidate@dckap.com";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $subject = 'Resume from candidate';</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $fileatt = $_FILES['resume']['tmp_name'];</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $fileatt_type = $_FILES['resume']['type'];</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $fileatt_name = $_FILES['resume']['name'];</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $fileatt_size = $_FILES['resume']['size'];</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> if($fileatt_size < 300000) { </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $headers = "From: $from";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $message="<p> Hi, <br/><br/>Please find the attached resume. </p>";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $email_message .= $message;</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $semi_rand = md5(time());</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $headers .= "\nMIME-Version: 1.0\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> "Content-Type: multipart/mixed;\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> " boundary=\"{$mime_boundary}\"";</span><br style="font-family: Times,"Times New Roman",serif;" /> <br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $email_message .= "This is a multi-part message in MIME format.\n\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> "--{$mime_boundary}\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> "Content-Type:text/html; charset=\"iso-8859-1\"\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> "Content-Transfer-Encoding: 7bit\n\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $email_message .= "\n\n";</span><br style="font-family: Times,"Times New Roman",serif;" /> <br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $data = chunk_split(base64_encode(file_get_contents($fileatt)));</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $email_message .= "--{$mime_boundary}\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> "Content-Type: {$fileatt_type};\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> " name=\"{$fileatt_name}\"\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> //"Content-Disposition: attachment;\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> //" filename=\"{$fileatt_name}\"\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> "Content-Transfer-Encoding: base64\n\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $data .= "\n\n" .</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> "--{$mime_boundary}--\n";</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $ok = mail($to, $subject, $email_message, $headers); // Mail sending to the requested Email Id</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> } else {</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $error_flag_filesize = 3;</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> }</span><br style="font-family: Times,"Times New Roman",serif;" /> <br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> } else {</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> $error_flag = 2;</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> } </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> }</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> }</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> }</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> ?></span><br style="font-family: Times,"Times New Roman",serif;" /> <br style="font-family: Times,"Times New Roman",serif;" /> <span style="color: blue; font-family: Times,"Times New Roman",serif;">Here we are showing the validation errors.</span></span><br />
<span style="font-size: large;"><span style="color: blue; font-family: Times,"Times New Roman",serif;"> </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <?php if(!empty($_FILES)) { if($error_flag == 1) { ?> </span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <div id="result-resume" name="result-resume" ></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <span style="color:red; margin-left:-245px;">please upload the file</span></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> </div></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <?php } elseif ($error_flag == 2) { ?></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <div id="result-resume" name="result-resume" ></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <span style="color:red; margin-left:-245px;">Please Upload Valid file Extension!</span></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> </div></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <?php } elseif ($error_flag_filesize == 3) { ?></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <div id="result-resume" name="result-resume" ></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <span style="color:red; margin-left:-245px;">Please upload the file less than 3MB</span></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> </div></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <?php } else { ?></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <div id="result-resume" name="result-resume" ></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <span style="color:red; margin-left:-245px;">Sent the resume successful</span></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> </div></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <?php }?></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <script>hideResult=document.getElementById("result-resume");</span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> setTimeout('hideResult.innerHTML=\'\'',7000); </script></span><br style="font-family: Times,"Times New Roman",serif;" /><span style="font-family: Times,"Times New Roman",serif;"> <?php }?></span><br />
</span></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-65505789404105478402012-02-21T02:23:00.000-08:002012-07-30T02:25:33.323-07:00How to integrate "xing" share button in your site?<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-qA6XZ_o2Ty4/UBZSkLOIYjI/AAAAAAAAAME/D_K8-lkTtgE/s1600/xing-share-phprockers.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="533" src="http://2.bp.blogspot.com/-qA6XZ_o2Ty4/UBZSkLOIYjI/AAAAAAAAAME/D_K8-lkTtgE/s640/xing-share-phprockers.jpg" width="640" /></a></div><br />
<div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">Steps:</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">1.Select The button layout as you want display in your site.</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">2.Provide the Url for which you are going to display the xing share count.(This is optional)</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">3.Select the language.</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">4.Copy the code in the textarea and paste it in your page.</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">Thats it. The All new Xing share button will be displayed in your site.</span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com1tag:blogger.com,1999:blog-3134317434590095750.post-9477684660103802492012-02-20T03:44:00.000-08:002012-02-20T03:44:26.773-08:00How to get the post tags by category name in wordpress?<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Times,"Times New Roman",serif; font-size: large;">Paste this code wherever you want to get post tags for specific category name in wordpress.<br />
<br />
<?php<br />
<br />
$cat_name = "Test Cat";<br />
query_posts('category_name='.$cat_name); //give the your category name here.<br />
<br />
if (have_posts()) : while (have_posts()) : the_post();<br />
$postTags = get_the_tags();<br />
if ($postTags) {<br />
foreach($postTags as $tag) {<br />
$all_tags[] = $tag -> name; <br />
}<br />
}<br />
endwhile; endif; <br />
<br />
if(!empty($all_tags)) {<br />
$unique_tags = array_unique($all_tags); //Removes the duplicates tags in the all_tags_arr array.<br />
echo '<pre>'.print_r($unique_tags, true).'</pre>'; <br />
} else {<br />
echo "No post tags are available for ".$cat_name." - category";<br />
}<br />
<br />
?></span></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-1050049009388489212012-02-17T07:47:00.000-08:002012-02-17T07:47:44.350-08:00How to get the posts by post tags in wordpress<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">We have easily get the post titles from from the post Id. So We have to try to get the post Id using the post tags. </span></div><div style="font-family: Times,"Times New Roman",serif;"><br />
</div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><?php <br />
<br />
global $wpdb;</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">$postTags = "Accidents";</span></div><div style="font-family: Times,"Times New Roman",serif;"><br />
</div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">//Below query can be used to get the post id using post tags.</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
$querystr ="SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id = (SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE taxonomy = 'post_tag' AND term_id = (SELECT term_id FROM wp_terms WHERE name ='$postTags '))";<br />
<br />
$result= $wpdb->get_results($querystr);</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">//$result have the post id. Now we easily get the post title or post information using post id.</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
foreach($result as $postid) {<br />
<br />
echo get_the_title($postid->object_id).'<br/>';<br />
<br />
}<br />
<br />
?></span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-89462789968425402792012-02-15T03:07:00.000-08:002012-02-15T03:08:33.502-08:00What is normalization?<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">Normalisation is a set of rules and techniques concerned with below:<br />
<br />
1. Identifying relationships among the attributes.<br />
2. Combining the attributes to form relations.<br />
3. Combining the relations to form a database.<br />
<br />
Normalised relational database gives several benefits to us:<br />
<br />
1. Elimination of redundant data storage in the database.<br />
2. Close modeling of real world entities, processes, and their relationships.<br />
3. Structuring of data so that the model is flexible.</span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-9191590396599238572012-02-14T02:25:00.000-08:002012-02-14T02:25:52.591-08:00Strip tags in PHP<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">strip_tags() function will return the string with stripped(removed) HTML and PHP tags.<br />
<br />
<?php<br />
<br />
$string = '<h2>This is PHP Rokcers blogspot.</h2><!-- Comment --> <a href="http://phprockers.blogspot.com/">phprockers</a>';</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
echo strip_tags($string);<br />
<br />
?><br />
<br />
Output:<br />
=======<br />
This is PHP Rokcers blogspot. phprockers<br />
<br />
If we want to allow some specific tags in our string, we have to given that tags as parameters in strip_tags function.<br />
<br />
<?php<br />
<br />
$string = '<h2>This is PHP Rokcers blogspot.</h2><!-- Comment --> <a href="http://phprockers.blogspot.com/">phprockers</a>';</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
echo strip_tags($string, '<h2><a>');<br />
<br />
?><br />
<br />
Output:<br />
=======<br />
<h2>This is PHP Rokcers blogspot.</h2><a href="http://phprockers.blogspot.com/">phprockers</a></span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-27892965994562071162012-02-08T01:55:00.000-08:002012-02-13T01:04:45.624-08:00Dynamic upload the multiple files in php with Javascript validation<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Times,"Times New Roman",serif; font-size: large;"><?php<br />
$con = mysql_connection() or (mysql_error();<br />
mysql_db_select("phprockers", $con) or mysql_error();<br />
?><br />
<html><br />
<script type="text/javascript" ><br />
function add_more() {<br />
var img = document.getElementById("image").value;<br />
img=parseInt(img)+1;<br />
var txt = "<br><input type = file name = images"+img+">";<br />
document.getElementById("image").value=img;<br />
document.getElementById("files").innerHTML += txt;<br />
}<br />
<br />
<br />
function validate(){<br />
var img = document.getElementById("image").value;<br />
img=parseInt(img);</span><br />
<a name='more'></a><span style="font-family: Times,"Times New Roman",serif; font-size: large;"> while(img > 0){<br />
var x=document.forms["myForm"]["images"+img].value<br />
if (x=="") {<br />
alert("please select file");<br />
return false;<br />
}<br />
img--;<br />
} <br />
}<br />
</script><br />
<body><br />
<form method="POST" name="myForm" action="" enctype="multipart/form-data" onSubmit="return validate();"><br />
<div id="files"> <input type="file" name='images1'/><br></div><br />
<input type="hidden" value=1 id="image" name="image"/><br />
<input type = "submit" name = "submit" value = "Submit" /><br />
<div style="cursor:pointer" onClick="add_more();">Attach File</div><br />
</form><br />
<?php<br />
if($_POST['submit']!="" ) {<br />
$upload_directory = 'upload/';<br />
for ($i = 1; $i <= $_REQUEST['image']; $i++) {<br />
$path=$_FILES['images'.$i]['name'];<br />
move_uploaded_file ($_FILES['images'.$i]['tmp_name'], $upload_directory . $_FILES['images'.$i]['name']);<br />
$query="INSERT INTO `browsefile`(`id`, `path`) VALUES (NULL,'$path')";<br />
mysql_query( $query );<br />
} <br />
}<br />
?><br />
</body><br />
</html></span></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com1tag:blogger.com,1999:blog-3134317434590095750.post-4944312979362971592012-02-06T09:23:00.000-08:002012-02-06T09:23:19.188-08:00Multiple File uploads in PHP<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><?php<br />
$con = mysql_connection() or(mysql_error();<br />
<br />
mysql_db_select("phprockers", $con) or mysql_error();<br />
?><br />
<form method="POST" action="" enctype="multipart/form-data"><br />
<br />
Images 1: <input type=file name='images1' ><br><br />
Images 2: <input type=file name='images2' ><br><br />
Images 3: <input type=file name='images3' ><br><br />
<input type="submit" name="submit" value="Submit" /><br />
<br />
</form></span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"></span></div><a name='more'></a><span style="font-size: large;"><?php<br />
if($_POST['submit']!="" ) {<br />
$upload_directory = '/upload/'; <br />
for ($i = 1; $i <= count($_FILES); $i++) {<br />
<br />
$path = $_FILES['images'.$i]['name'];<br />
move_uploaded_file($_FILES['images'.$i]['tmp_name'], $upload_directory . basename($_FILES['images'.$i]['name']));<br />
$query="INSERT INTO browsefile (id,path) values('$path')"; <br />
mysql_query( $query ); <br />
<br />
}<br />
}<br />
?></span></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-4915915407987339322012-02-03T08:41:00.000-08:002012-02-03T08:41:37.021-08:00Important functions in Wordpres<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"> Wordpress Functions:</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">================</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">get_the_excerpt() - It can be used to get the post excerpt content in the current post.<br />
<br />
get_post($post->ID) - It can be used to get the post details about current post. It has title,categoryid, category name, post status etc. Here post->ID is optional.<br />
<br />
get_the_post_thumbnail($page->ID,array(150,200),'thumbnail') - It can be used for retrive the thumbnail image for the post.<br />
<br />
the_title() - It can be used for retrive the title for current post.</span></div><a name='more'></a><span style="font-size: large;"><br />
get_the_title(ID) - It can be also used to get the title for the post.<br />
<br />
get_cat_name( $cat_id ) - It can be used to get the category title for that category id.<br />
<br />
get_post_type(ID) - get the post type for that post id.<br />
<br />
get_the_author() - get the author name for current post.<br />
<br />
get_categories() - get the all the categories in wp.<br />
<br />
get_the_content() - It can be used for the get the content for current post.<br />
</span></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-4235292454171362402012-02-03T06:00:00.000-08:002012-02-03T06:00:01.451-08:00Limitatin in MYSQL<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">Table attribute names are eliminated after 31 characters in the database.<br />
<br />
The maximum character of database and table is 122 characters in the mysql.<br />
<br />
The maximum number of table in a mysql database is 1792.<br />
<br />
The maximum number of database in mysql is 20320.<br />
<br />
The maximum number of attributes (that is, columns and indexes) per table is 128 characters. <br />
<br />
The maximum number of attributes per key is 32. <br />
<br />
The maximum permitted size of one row in table is 8052 bytes.</span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-72949552933435923552012-02-01T07:50:00.000-08:002012-02-01T08:04:43.817-08:00Get the second highest salary from employee table in mysql<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">We have get the second, third, fourth etc. hightest salary from the employee table very easily in mysql/sql.<br />
<br />
Getting max highest salary:<br />
===================<br />
<br />
SELECT max(salary) as salary FROM employee;<br />
<br />
Getting N th highest salary syntax:<br />
========================<br />
<br />
SELECT salary FROM employee as emp WHERE (n-1) = (SELECT count(*) FROM employee as emp2 WHERE emp2.salary > emp.salary)<br />
<br />
Getting 2nd maximum salary:<br />
=====================<br />
Above syntax, subsitute n=2, then we have to get second max salary.<br />
<br />
SELECT salary FROM employee as emp WHERE (2-1) = (SELECT count(*) FROM employee as emp2 WHERE emp2.salary > emp.salary)</span></div><a name='more'></a><span style="font-size: large;"><br />
(OR)<br />
<br />
SELECT max(salary) as salary FROM employee WHERE salary < (SELECT max(salary) FROM employee)</span><br />
<span style="font-size: large;"><br />
</span><br />
<span style="font-size: large;">(OR)<br />
<br />
SELECT salary FROM employee ORDER BY salary DESC LIMIT 1,1</span><br />
<span style="font-size: large;"><br />
Getting First Three maximum salary:<br />
=======================<br />
<br />
SELECT salary FROM employee ORDER BY salary DESC LIMIT 0,3.<br />
<br />
This is very useful for retriving the highest three maximum salary from the employee table. </span></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com2tag:blogger.com,1999:blog-3134317434590095750.post-80189983564542133872012-01-31T05:11:00.001-08:002012-01-31T05:11:59.066-08:00mysql_escape_string in php<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">This function escacpe the single quotes, double quotes and unwanted symbol from our passing strings. <br />
<br />
Format :<br />
========<br />
mysql_escape_string(string_name);</span></div><div style="font-family: Times,"Times New Roman",serif;"><br />
</div><div style="font-family: Times,"Times New Roman",serif;"></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">Example:</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">======<br />
$first_name = mysql_escape_string($first_name);<br />
<br />
<br />
Keep in mind:<br />
=============<br />
mysql_escape_string() cann't escape the % and _. </span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-20014857896203140792012-01-31T04:12:00.000-08:002012-01-31T04:12:06.015-08:00List out all the mysql database name in php<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">List out all the mysql database name using follwing php code.<br />
<br />
<?php<br />
<br />
error_reporting(E_ALL);<br />
<br />
$connection = mysql_connect('localhost', 'root', '');<br />
<br />
$database_list = mysql_list_dbs($connection);<br />
<br />
$count = mysql_num_rows($database_list);<br />
<br />
for($i=0;$i<$count;$i++) {<br />
<br />
echo mysql_db_name($db_list, $i) . "<br/>";<br />
}<br />
<br />
?></span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com0tag:blogger.com,1999:blog-3134317434590095750.post-61121047023553017142012-01-31T02:10:00.000-08:002012-01-31T02:21:02.549-08:00How to get the mysql last inserted id using PHP?<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">We have to easily get the last inserted id in mysql table using below code.</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><?php</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">$connection = mysql_connect('localhost', 'MYSQL_USERNAME', 'MYSQL_PASSWORD') or mysql_error();</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">mysql_select_db('DATABASE_NAME', $connection) or mysql_error();</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">$query = "INSERT INTO emp_table (emp_id, emp_name, emp_qualification, emp_salary) VALUES ('SC70699', 'Ramakrishnan', 'MCA', '13186')";</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">mysql_query($query );</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">$last_insert_id = mysql_insert_id();</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">echo "Last insert id in employee table: ".$last_insert_id;</span><br />
<br />
<span style="font-size: large;">mysql_close($connection) ;</span><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;"><br />
</span></div><div style="font-family: Times,"Times New Roman",serif;"><span style="font-size: large;">?></span></div></div>Ramhttp://www.blogger.com/profile/11521045862668163635noreply@blogger.com1