Yes. This can be done by posting the data back to the server and outputting the results to the browser.
You would need to create your HTML form which submits the content you wish to manipulate
<form method="post" target="myproject.php">
<input type="text" name="usertext"/>
</form>
On the PHP side (in this case in "myproject.php"), you can read the post data and act accordingly.
<?php
if(array_key_exists('usertext', $_POST)){
$submittedValue = $_POST['usertext'];
}
The key item to note is that the posted data can be accessed as key values in the array $_POST. You can then do whatever you wish with the posted value.
If you want to maintain an ongoing list of items that the user is submitting, you could do it a couple of ways. To maintain it permanently, you'll probably want to open up a database (check out "mysqli" on the the documentation for PHP). If you only want it for that active user session, then you might want to consider another global array called $_SESSION. It is an array that gets stored on the server, retaining data for any user between page loads. The code above could be modified to use it like so:
<?php
session_start();
if(!array_key_exists('submittedValues', $_SESSION)){
$_SESSION['submittedValues'] = array();
}
if(array_key_exists('usertext', $_POST)){
$_SESSION['submittedValues'][] = $_POST['usertext'];
}
Now you can loop through the array $_SESSION['submittedValues'], dealing with every value the user has submitted in their current session.
How do you create an administration page using php?
Process is the same as if creating any other php script, but on top of it, you need to integrate authentization system (so you can login as administrator).
Best way of implementation is using $_SESSION to store needed information during the session (e.g. $_SESSION['logged']=true, $_SESSION['id'], etc.).
Comparing a field from a table with a field from a different table and using PHP and MySQL?
That will depend on the relationship between the two tables. Assuming it's a simple link between the two tables, then it can be done pretty easily.
For example, take two tables, "nuts" and "bolts". Perhaps you would want to compare the price per quantity of each of those, and that value is stored in the table. You could do it this way:
...
$query = mysql_query("SELECT nuts.price AS nutprice, bolts.price as boltprice FROM nuts JOIN bolts ON nuts.quantity = bolts.quantity");
while( $data = mysql_fetch_array($query)){
do_comparison($data['nutprice'], $data['boltprice']);
}
...
How you can validate tha current date in vc?
The current date does not need validation; it can be read directly from the system clock. However, validating a date against the system clock does not guarantee that date is current; it is only current when the system clock is set correctly.
How to put a Localhost site online. free Habbo retro PHP?
If you are running the Habbo retro PHP(which I don't know what that is, btw) locally on your PC, then you already have the first step: an HTTP server capable of parsing/interpreting PHP and maintaining database operations and connectivity if applicable. You would then use your network's external IP address as a URL to point to the site. This is the same way that any website on the internet works except that in 99.9% of cases you are using a DNS entry(a domain name) that serves as a proxy for the actual address.
The problem is, you can't always do this. With my current Charter provided internet access, I can access my Apache server anywhere with internet. The problem is though my IP changes so if I am not home to re-query for my new DHCP lease then I cannot access. ATT on the other hand would not allow external traffic to view my IP this way and would not disable it in the modem. This is a problem because some ISPs will allow you to access and modify your modem, but others will give you a modem and a router and the modem holds the settings required for THEIR side of things while the router would hold settings for the bits of your network you can control and customize.
You *could* get a static IP address and a domain name and run it on the open net this way, but most ISPs are going to require you to upgrade to a business internet account and your computer(although potentially quite powerful) is not going to be able to handle very much load as far as games(I'm assuming that Habbo is in reference to Habbo Hotel?) At the end of the day, it's just not a server.
The best method for overcoming HTML's stateless-ness (?) is by storing information in the $_SESSION variable. Another popular (although less secure) method is with the $_COOKIE variable.
Using the $_SESSION variable:
The $_SESSION variable is a way to maintain session specific information. While any kind (or amount) of information can be stored, I personally only use it to store a user's ID, which I can reference to grab things like site permissions from a database record. This keeps unnecessary server overhead down. The session is destroyed as soon as the user's browser is closed.
Reserved Variable: http://www.php.net/manual/en/reserved.variables.session.php
Session Reference: http://au2.php.net/manual/en/refs.basic.session.php
Session Functions: http://au2.php.net/manual/en/ref.session.php
Using the $_COOKIE variable:
The $_COOKIE variable allows you to store an associative array of values on a user's PC. This information is not destroyed when the user closes their browser and remains persistent until either the cookie expires (can be set for up to 1 year) OR the user clears their browser history and settings. DO NOT store account information such as usernames, ID's and passwords in a cookie.
Reserved Variable: http://www.php.net/manual/en/reserved.variables.cookies.php
W3Schools Tutorial: http://www.w3schools.com/PHP/php_cookies.asp
How do you convert xlsx to xls using php?
since XLS and XLSX are proprietary formats of Microsoft products, I'm not sure there is a (free) PHP way to do so. you can export your data in CSV, which is easily opened in Microsoft Excel or OpenOffice Calc
The bubble sort algorithm can be applied to an array of characters. Every character can be translated to an integer equivalent via the ascii table
What is the best way to read large files in PHP?
Using the standard file() function to read large text files (say greater than 10 Mb) may give problems. You should use fopen() fread() fgets() instead.
I have searched a lot to find where i can create free
email and web forms.Finally after lot of searching i find a
site where i can create email forms,web forms, php forms, contact
forms for free and in easy way.
its link is http://www.ezcontactform.com/
How do you enable dynamic loading in PHP?
To enable dynamic loading of extensions, set enable_dl option in php.ini to 1
How do you retrieve a date field from MS Access through PHP?
Use this class: http://www.phpclasses.org/browse/package/2036.html Or if you have trouble with that, look through some of the other classes under the "database" category on that site. -DJ Craig
What is the fundamental questions would you ask when designing forms and reports?
Without knowing the entire background to the form, can I -your customer- complete it without detailed help text? If not, consider using simpler/more common terms for frields.
Does it make sense considering your database design? If not, reconsider the form or your database.
Is it easy to program? If not, it could be more complex to a customer than you may think, or may be an incorrect way of approaching the problem at least.
It is a matter of personal preference. Each one comes with its plus and minus points. You need to choose according to your requirements, skills and preference.
How do you sort the given contents of an array?
You would sort the given elements of an array by a bubble sort or heap sort code!!
How do you copy a database of mysql in wamp server from one computer to another?
You have several options:
* copy the database files from mysql/data/<database_name> to a new mysql Installation
* use mysqldump utility to export the data from your database and load it into the new mysql installation
* setup replication
Why there is no boolean operator in php?
There are several boolean operators in PHP. I'm not able to provide you with it's full list, but here are some of the most used ones:
&& - AND
- OR
! - NOT
How can you populate a Dropdown with an Array from a Database using PHP?
This can be done with any Database system as the clever part is within the PHP.
There are two ways of doing this. The first method is having each record as a new selection. The second is having one field of the selection.
I'm going to use 'DATABASE {' and '} DATABASE' in order to show you where to put your 'Database {' and your closing '}' for the query.
Each Record
Assuming that you have at least two fields. One called value one called text then the following would work. (If your value is always the same as the Text shown to the user then you can change the set of text to value)
Echo '<select name="myselect">';
#DATABASE {
$current_value = $DATABASE['value'];
$current_text = $DATABASE['text'];
$myarray[] = '<option value="' . $current_value . '">' . $current_text . '</option>'; #A*
} DATABASE
Foreach($myarray as $key => $value){
Echo $value;
}
Echo '</select>';
Of course in this method you do not require an array as such. Due to the fact that on line A* could echo the value there and then.
One Field
This would be used more in the cases in which the table is built for forms and works like a Content Management System (CMS).
Firstly set out your record contents as: (I'm assuming here that the field is called dropdown)
I am a value[nowtext]I am some text[nextopt]I am a second Value[nowtext]I am some more text
Now let me explain. If you split this up in to [nextopt] there are two options. If you then split each again by [nowtext] you'll find 2 in between the [nextopt].
In this case, the first item set is the value of the Dropdown. The second is then the text and is split using [nowtext].
There are two functions in PHP which will help us. The first is called explode(); and this works like myfeild.split(); in Javascript. The second is implode();. Explode() is making an array. Think of it as, Explode the information into smaller chunks. Implode is the opposite, this takes an Array and turns it in to a String. (I've added two links to W3schools for reference on these tags)
Fairly simple when you understand how they work. Here's an example:
Echo '<select name="myselect">';
#Database {
$current_dropdown = $DATABASE['dropdown'];
$dropdown_array_a = explode('[nextopt]',$current_dropdown); #Makes an array
Foreach($dropdown_array_a as $key => $value){ #Runs for each item in array and loads in the key and the value of the array.
$dropdown_array_b = explode('[nowtext]',$value
Echo '<option value="' . $dropdown_array_b[0] . '">' . $dropdown_array_b[1] . '</option>';
}
# } DATABASE
Echo '</select>';
That was two of the many ways to perform this task. A link to the reference of Explode, Implode, Arrays and Foreach has been added to the Question.
How do you run a MySQL query from PHP file?
Here is a simple script that you can do to run a MySQL query after you have set a database up.
<?php
// Database Settings
$db['hostname'] = "localhost";
$db['username'] = "<db username>";
$db['password'] = "<db password>";
$db['database'] = "<db name>";
// Connect to MySQL
$connect = mysql_connect($db['hostname'], $db['username'], $db['password']);
// Select Database
mysql_select_db($db['database'], $connect);
// Do MySQL Query
mysql_query("INSERT INTO table_name SET field_name = '1234567890'");
// Close MySQL
mysql_close($connect);
?>
Obviously you will need to use your own MySQL settings and database details, but this gives you a general overview of how you can do it.
How do you delete all table in a database?
Unless you want to drop (delete) the entire database, you will must delete tables individually.
To delete tables individually, execute the query "SHOW TABLES" in your database which will return a list of all table names. Iterate through that resultset and execute "DROP TABLE {$table_name}"
How do you find the length of string without using strlen function in MySQL?
SELECT char_length (...) FROM ...
How do you define a constant in PHP?
You can define a constant using the define() directive.
you can use this a number of ways;
to define a variable to a constant do:
$string = "hello";
define("string",$string);
to define a string to a constant use:
define("hello","there");
to define a integer or other numerical value use:
define("number",1.0);
Summery:
to define a string use quotes as you would do a string.
Unlike variables in PHP a constant cannot be changed or undefined once it is defined. Constant remains automatically globally throughout the script. It means that it can be accessed from inside a function. e.g.
define("Program" , "This is my first line of code!");
function simTest() {
echo Program;
}
simTest();
?>