Frequently Asked Questions
1. How to create multiple rows using javascript?
2. Is it possible to integrate Highslide codings in the website?
3. What is the syntax for getting the url value?
4. What is the procedure to read the xml file using php?
5. How to create rss feeds using php?
6. How to use post method in Ajax?
7. How to configure php in IIS?
8. Is there any Free source to configure php5 in IIS?
9. How to use div concepts in php?
10. Dont you know how to use peel effect in website?
11. How to submit flash values to php?
12. Where can i get free photoshop,flash,Dream weaver,actionscript tips & tricks ?
13. Which method in php should i use to get the value of the url?
14. How to make a website rich,userfriendly & browser compatability using php?
15. Will PHP5 work in IIS?
You can get PHP tutorials, ajax codings, free html,javascript tips & tricks, making webpages faster with minimizing mysql query, create your site through xml, helpful tips & tricks for creating websites, control the site through xml, get ajax codings using get & post method in ajax method, convert videos to any format using FFMPEG PHP, create multilanguage website, create content in chinese, send mail in chinese language, Iframe virus removal, free sms using php webservice,
Friday, August 29, 2008
Add Multiple rows dynamically by clicking Add New Button
Copy the javascript coding & paste it in head.
<1script type="text/javascript">
function AddRow()
{
var dcname =document.getElementById("dcname");
var dqty =document.getElementById("dqty");
var dstype =document.getElementById("dstype");
var dnature =document.getElementById("dnature");
var morerow=document.getElementById("tbl")
var newtr = document.createElement("tr");
var newtd1 = document.createElement("td");
newtd1.innerHTML = dcname.innerHTML;
newtr.appendChild(newtd1);
var newtd2 = document.createElement("td");
newtd2.innerHTML = dqty.innerHTML;
newtr.appendChild(newtd2);
morerow.appendChild(newtr);
var newtd3 = document.createElement("td");
newtd3.innerHTML = dstype.innerHTML;
newtr.appendChild(newtd3);
var newtd4 = document.createElement("td");
newtd4.innerHTML = dnature.innerHTML;
newtr.appendChild(newtd4);
}
<1/script>
Paste the below content in the body section
<1table width="100%">
<1tbody id="tbl">
<1tr>
<1td><1div align="center">Chemical Name <1/div><1/td>
<1td><1div align="center">Quantity<1/div><1/td>
<1td><1div align="center">Storage Type <1/div><1/td>
<1td><1div align="center">Nature Of <1/div><1/td>
<1td> <1/td>
<1tr>
<1td><1input name="cname[]" type="text" id="cname" style="font-size:10;">
<1td><1input type="text" name="qty[]" id="qty" style="font-size:10;">
<1td><1input name="stype[]" type="text" id="stype" size="10">
<1td><1input type="text" name="natureof[]" id="natureof" style="font-size:10;">
<1td><1input name="Add" type="button" value="add" onclick="return AddRow();">
<1/tr>
<1/tbody>
<1div id="dcname" style="display:none; visibility:hidden"><1input name="cname[]" type="text" id="cname" size="10"><1/div>
<1div id="dqty" style="display:none; visibility:hidden"><1input type="text" name="qty[]" id="qty" size="10"><1/div>
<1div id="dstype" style="display:none; visibility:hidden"><1input type="text" name="stype[]" id="stype"><1/div>
<1div id="dnature" style="display:none; visibility:hidden">
<1script type="text/javascript">
function AddRow()
{
var dcname =document.getElementById("dcname");
var dqty =document.getElementById("dqty");
var dstype =document.getElementById("dstype");
var dnature =document.getElementById("dnature");
var morerow=document.getElementById("tbl")
var newtr = document.createElement("tr");
var newtd1 = document.createElement("td");
newtd1.innerHTML = dcname.innerHTML;
newtr.appendChild(newtd1);
var newtd2 = document.createElement("td");
newtd2.innerHTML = dqty.innerHTML;
newtr.appendChild(newtd2);
morerow.appendChild(newtr);
var newtd3 = document.createElement("td");
newtd3.innerHTML = dstype.innerHTML;
newtr.appendChild(newtd3);
var newtd4 = document.createElement("td");
newtd4.innerHTML = dnature.innerHTML;
newtr.appendChild(newtd4);
}
<1/script>
Paste the below content in the body section
<1table width="100%">
<1tbody id="tbl">
<1tr>
<1td><1div align="center">Chemical Name <1/div><1/td>
<1td><1div align="center">Quantity<1/div><1/td>
<1td><1div align="center">Storage Type <1/div><1/td>
<1td><1div align="center">Nature Of <1/div><1/td>
<1td> <1/td>
<1tr>
<1td><1input name="cname[]" type="text" id="cname" style="font-size:10;">
<1td><1input type="text" name="qty[]" id="qty" style="font-size:10;">
<1td><1input name="stype[]" type="text" id="stype" size="10">
<1td><1input type="text" name="natureof[]" id="natureof" style="font-size:10;">
<1td><1input name="Add" type="button" value="add" onclick="return AddRow();">
<1/tr>
<1/tbody>
<1div id="dcname" style="display:none; visibility:hidden"><1input name="cname[]" type="text" id="cname" size="10"><1/div>
<1div id="dqty" style="display:none; visibility:hidden"><1input type="text" name="qty[]" id="qty" size="10"><1/div>
<1div id="dstype" style="display:none; visibility:hidden"><1input type="text" name="stype[]" id="stype"><1/div>
<1div id="dnature" style="display:none; visibility:hidden">
<1input type="text" name="natureof[]" id="natureof" size="10"><1/div>
That's it now you have created a single row and by clicking add new it will add any number of rows dynamically
Note : Remove 1 on every html tag
Thursday, August 28, 2008
Read XML Using PHP DOM
This tutorial is for PHP starters as well as for those who are using XML parser functions to read/write XML files. This tutorial will not go into details on XML. The focus will be more on the Document Object Model (DOM) extension.
This should not be confused with DOM XML extension, which is not packaged into PHP5 and will never be (according to php.net). DOM extension allows PHP users to use the DOM functions. The function then allow users to read, write, rename tags and do all types of crazy stuff with XML documents.
First we need a XML document to experiment with. I have created a simple XML document and named it readfromxml.xml
readfromxml.xml
<1?xml version="1.0" encoding="ISO-8859-1"?>
<1html>
<1head>
<1pagename>Current page name<1/pagename>
<1title>Title for Pagename<1/title>
<1keyword>meta keyword for current page<1/keyword>
<1description>meta Description for current page<1/description>
<1/head>
<1/html>
This XML document stores pagename,title of the page,keyword for the page and description for the page. You can create one for any type of webpage to create keywords, description dynamically & manage for every single page. Every note in this XML file beings < with and ends with >. Within the tab I have created a tab for the keyword ( ),description ( ),title ( ),pagename ().
Next step is to read this XML and display the results on a web page.
Create another file and call it readfromxml.php. Copy the following code into it and run it.
// DOMElement->getElementsByTagName() -- Gets elements by tagname
// nodeValue : The value of this node, depending on its type.
// Load XML File. You can use loadXML if you wish to load XML data from a string
$objDOM = new DOMDocument();
$objDOM->load("readfromxml.xml"); //make sure path is correct
$note = $objDOM->getElementsByTagName("head");
// for each note tag, parse the document and get values for
// tasks and details tag.
foreach( $note as $value )
{
$page = $value->getElementsByTagName("pagename");
$page = $page->item(0)->nodeValue;
if($page == $pagename)
{
$title = $value->getElementsByTagName("title");
$title = $title->item(0)->nodeValue;
$keywords = $value->getElementsByTagName("keyword");
$keywords = $keywords->item(0)->nodeValue;
$description = $value->getElementsByTagName("description");
$description = $description->item(0)->nodeValue;
}
}
?>
create a webpage as index.php and copy the following content and paste it in index.php
$pagename = "index.php";
require("readfromxml.php");
?>
<1!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<1html xmlns="http://www.w3.org/1999/xhtml">
<1head>
<1meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<1META NAME="DESCRIPTION" CONTENT="" />
<1META NAME="KEYWORDS" CONTENT="" />
<1title><1/title>
<1/head>
<1body>
<1/body>
<1/html>
This tutorial is a kick start for beginners. You can retreive data from a database and create a XML document on-the-fly with DOM functions, rename tabs in an existing XML document and validate format.
Note : Remove 1 on every tag
This should not be confused with DOM XML extension, which is not packaged into PHP5 and will never be (according to php.net). DOM extension allows PHP users to use the DOM functions. The function then allow users to read, write, rename tags and do all types of crazy stuff with XML documents.
First we need a XML document to experiment with. I have created a simple XML document and named it readfromxml.xml
readfromxml.xml
<1?xml version="1.0" encoding="ISO-8859-1"?>
<1html>
<1head>
<1pagename>Current page name<1/pagename>
<1title>Title for Pagename<1/title>
<1keyword>meta keyword for current page<1/keyword>
<1description>meta Description for current page<1/description>
<1/head>
<1/html>
This XML document stores pagename,title of the page,keyword for the page and description for the page. You can create one for any type of webpage to create keywords, description dynamically & manage for every single page. Every note in this XML file beings < with and ends with >. Within the tab I have created a tab for the keyword ( ),description ( ),title ( ),pagename ().
Next step is to read this XML and display the results on a web page.
Create another file and call it readfromxml.php. Copy the following code into it and run it.
// DOMElement->getElementsByTagName() -- Gets elements by tagname
// nodeValue : The value of this node, depending on its type.
// Load XML File. You can use loadXML if you wish to load XML data from a string
$objDOM = new DOMDocument();
$objDOM->load("readfromxml.xml"); //make sure path is correct
$note = $objDOM->getElementsByTagName("head");
// for each note tag, parse the document and get values for
// tasks and details tag.
foreach( $note as $value )
{
$page = $value->getElementsByTagName("pagename");
$page = $page->item(0)->nodeValue;
if($page == $pagename)
{
$title = $value->getElementsByTagName("title");
$title = $title->item(0)->nodeValue;
$keywords = $value->getElementsByTagName("keyword");
$keywords = $keywords->item(0)->nodeValue;
$description = $value->getElementsByTagName("description");
$description = $description->item(0)->nodeValue;
}
}
?>
create a webpage as index.php and copy the following content and paste it in index.php
$pagename = "index.php";
require("readfromxml.php");
?>
<1!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<1html xmlns="http://www.w3.org/1999/xhtml">
<1head>
<1meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<1META NAME="DESCRIPTION" CONTENT="" />
<1META NAME="KEYWORDS" CONTENT="" />
<1title><1/title>
<1/head>
<1body>
<1/body>
<1/html>
This tutorial is a kick start for beginners. You can retreive data from a database and create a XML document on-the-fly with DOM functions, rename tabs in an existing XML document and validate format.
Note : Remove 1 on every tag
Get the current page url using php
//This function returns the full url of the current page
function getcurrentpageurl() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
echo getcurrentpageurl();
?>
//This function returns the filename alone
function getcurrentpagename() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
echo "The current page name is ".getcurrentpageurl();
?>
function getcurrentpageurl() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
echo getcurrentpageurl();
?>
//This function returns the filename alone
function getcurrentpagename() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
echo "The current page name is ".getcurrentpageurl();
?>
Subscribe to:
Posts (Atom)