How retrieve xml data using php?
Ypu can use file handling function to read XML
file_get_contents()
file()
fopen()
Use SimpleXML Library
simplexml_load_string - Interprets a string of XML into an object
simplexml_load_file - Interprets an XML file into an object
How does scripting change a program?
Scripting does not ever really change the program. Although it is much like programming, the method of how the code is used is different. In Programming you write your desired code and then compile it into an excutable which is directly associated with machine code. While scripting allows the coder to write the desired information or code which is compiled every time it is requested. How ever scripting allows you to achieve your desired result by making your code. Then when you request it the preproccessor applications will take the code and read it much like you would a set of cooking instructions or map directions. You all ready know what one cup is, same as water and a pan. So the instructions tell you to add One cup of Water into the Pan, thus you do many small steps such as grab the cup, turn on the facet, but all those are all ready known and not needed in the instructions.
How do you reverse a string with array and function?
<?php
$str = "1234567";
$strArr = str_split($str); //split up $str by 1 character
$strlen = strlen($str) - 1; //get length of $str - 1 since the $strArr starts at 0
for($i=$strlen;$i>=0;$i--)
{
echo $strArr[$i];
}
?>
Draw a B-tree of order 3 for the following sequence of keys 2 4 9 8 7 6 3 1 5 10?
2 4 6 7 8 9
split to become
6
/ \
2 3 4 7 8 9
6
/ \
1 2 3 4 7 8 9
6
/ \
1 2 3 4 5 7 8 9
6
/ \
1 2 3 4 5 7 8 9 10
What is PHP web mailer and SMTP?
SMTP stands for Simple Mail Transfer Protocol. PHP has a built-in function called mail() that takes 5 arguments. TO, Subject, Message, Headers, Additional Parameters. Hostmysite.com has some examples in their support section but below is another example. Here is the syntax you will need to use:
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Draw a program flowchart to find the least number in a list of 100 numbers?
It's a bit difficult to show a flowchart using nothing but words, but here goes:
start
let list[] be 100 random values
let best be value of list[0]
let index be 1
repeat
is value of list[index] less than best?
YES: let best be value of list[index] {continue}
NO: {continue}
increment index
is index less than 100?
YES: {go to repeat}
NO: {continue}
print value of best
end
Previous answer:
start test number =100 count = count +1 list number =< test number if true testnumber = list number count = 100 goto end else start end
The previous answer assumes 100 to be largest number in the list. What happens when all of the numbers in the list happen to be greater than 100? Also, previous answer exits the loop prematurely as soon as any number equal or smaller than 100 is located. To locate the smallest number in a list, the entire list must be compared with the current best, which is initially taken to be the first number in the list.
How do you make a loop radio buttons that saves to database?
Radio Buttons allow only one value between them. For eg. Male or Female. So there is no point in declaring a loop for it. You could store the value like any other form elements. If you declare different names for radio buttons then & then only use this:
Orange
Apple
Grapes
File: action.php
if(isset($_POST['submit']))
{
if(isset($_POST['radio1']))
{
$value1 = $_POST['radio1'];
}
else
{
$value1 = "";
}
if(isset($_POST['radio2']))
{
$value2 = $_POST['radio2'];
}
else
{
$value2 = "";
}
if(isset($_POST['radio3']))
{
$value3 = $_POST['radio3'];
}
else
{
$value3 = "";
}
$value = $value1." ".$value2." ".$value3;
// Store the $value in database
}
?>
Ideally a checkbox is better suited to have multiple values
What is the difference between an array shift and unsetting a variable in PHP?
By shifting the values in an array, you are moving a key's value to the previous key. The very first key's value is obliterated. By shifting all values in the array, all keys will have a value of NULL. Unsetting a variable is entirely different -- performing a variable unsetting causes the variable to have a value of NULL, as if it was never set.
How do you check which extensions are dynamically loaded in PHP?
To get the list of currently loaded extensions within a PHP program. Use get_loaded_extensions() function.
To check what extensions are loaded by PHP on a given server, type this on the command line:
php -m
$key | $value |
How do you validate and retrieve data from database?
How do you validate and retrieve data from database?" How do you validate and retrieve data from database?"
How do you populate values of combobox using server side scripting as php?
I am assuming you already have a mysql connection function/string in place
Now select the database
mysql_select_db("db_name"); // Put the name of your database in place of db_name
// Add the column you want data from in place of ID
// Add the name of your table in place of table_name
$query = mysql_query("SELECT ID FROM table_name");
// This gets a bit complicated but it helps with debugging
?>
while($result = mysql_fetch_array($query))
{
$value = $result['ID'];
?>
}
?>
If you want value of another combobox by selecting a combobox then use of AJAX is helpful
What is the php code to close the existing window using button?
It is not a PHP code but a Javascript code. w3schools.com has all the answers you need about Javascript. It will teach you how to use the code and implement it into your website. If you're creating your own websites I suggest you actually learn the code. It will come in handy later on.
How to submit the four page in one button using one form in php?
Use Jquery .hide() and .show() functionality. That way one form can extend up to 4 pages and the final submit button will submit the button while just use the button element on the first 3 pages. A small example
<script type="text/javascript" language="javascript">
function showPart2()
{
$('#next').click(function()
{
$('#page1').hide();
$('#page2').show();
});
}
</script>
<body>
<form>
<div id="page1">
// Code here
<input type="button" name="next" id="next" onclick="javascript:showPart2();"/>
</div>
<div id="page2">
// Code here
// Similar 2 buttons to navigate to Previous & Next and functionality of hide & show
</div>
</form>
</body>
What is an Array and to use Array in Action script?
Array is a ranged variable, using it is required by many actions.. like where you going to processing data from a file where there is n lines in a file and you want to get one line of it..
ex: if variable $line is an array of lines in a text file:
$line[1] is second line of the file... just keep it in mind arrays starts from zero :) it means line 1 of the file will be accessed with $line[0];
Document created in Excel is referred to as a?
An Excel Book or Excel Workbook with the files extension of .xlsx
Can you explain the Post function in PHP?
Posts ($_POST) is used to take information from a form to the next screen (passing it along). You name the feild and then that becomes the name you will call back. For example:
The Name there is quantiy. Therefore when the feild is carried over you can call back the variable using:
$quantity = $_POST['quantity'];
?>
Ensure you use '' ( $_POST['quantity'] ) for statements and either use (int) or take them out for numbers:
Statment
$quantity = $_POST['quantity'];
?>
Number
$quantity = $_POST[quantity];
?>
Also a Number
$quantity = (int)$_POST['quantity'];
?>
How do you count the number of elements in an array using PHP?
Using the function "count".
<?php
$foo = array("John", "Jacob", "Jingleheimer", "Schmidt");
echo count($foo); // <-- outputs the number 4
?>
How do you install PHP 5.2 on your server?
Visit the downloads section of the PHP website (see the related links), and find the PHP 5.2 download for your operating system. Install the package accordingly -- which is an entirely customized step, depending on your operating system.
Php code to insert value from textbox into dropdownlist?
Once you submit a form you can use the $_POST[] array to grab the data from a form with PHP. You can then use this data to insert it into a form. Here is an example:
<?php
if($_POST['submit']){
$text_box_contents = $_POST['comments'];
echo ' <select> <option>'.$text_box_contents .'</option> </select>';
}else{
echo ' <form method="post" action="$_SERVER['self']">
<textarea name="comments" cols="40" rows="5">
hostmysite.com
Enter your comments here...
</textarea><br>
<input type="submit" value="Submit" /> </form>';
}
?>
How do you create a table in dreamweaver?
using the mysql command "create table table_name" we can create a table in dreamweaver.
How can a called function determine the number of arguments that have been passed to it?
It is not the function but the compiler or interpreter which interprets the code. When the program is compiled and run the compiler checks the entire code line by line to check which function is called. If you encounter polymorphism in other Object Oriented Languages it would be more clear how a function with same name and different arguments are called.
How do you insert files into a database using PHP?
Im not entirely sure what you mean. But say you have some text you want to save and load later on... you can put it into a database (e.g. MySQL) or even better a flat file database (e.g. a simple text file). Say for example you have a chatbox. And you want to save the text into a .txt file so u can load it later on using php as well. However if you want to save important data (e.g. passwords credit card information) then i would recommend using a proper database like phpMyAdmin. If u need to no more just send an email to wasim-ilyas@hotmail.co.uk (my email address). Thanks,
Wasim Ilyas