Hi guys,

I am a little new to this stuff but have done a few research regarding PHP.

Currently, I am trying to learn PHP to allow a web portal to interact with data stored on MySQL database.

In other words, lets say I have a website that displays information by retrieving data from a MySQL database via PHP. That means I would need to practice writing PHP scripts to do that.

My question:

I have read a few places with varying answers, so I will ask for a recommendation here:

I am using Windows 7 and I am wondering which program and what I need to go about starting this? (For example, if you write Java, you might want to download Eclipse to be able to practice writing Java code).

For PHP, there are two things I am concerned with right now in terms of learning and seeing does my code work:
1: It is not clear what I need to be able to test the code for its correctness and also...

2: Be able to run it on a MySQL database and see can I output data properly to a website.

Thank you,

Limiter

first you have to have
1.apache - for the webserver
2. php
3. mysql - for the database
or you could download xampp (it has all of the stuff above)

you could choose any text editor
i am using subline text editor

as code739 said
u need a editor, sublimetext2 editor is very good and you can also use dream weaver
and for the correctness of code there is nothing in php to debug code you have echo your out put and put
mysql_error() function for any db error and in phpmyadmin you test query and convert it into php code their is option in phpmyadmin to convert query for your php code so you can use that query.

For the webservice, I use WAMP, it is simple to use, at least for me.
To test the code, you will have to figure out ways to do it. You can print your results/variables to make sure the correct data is in it. Sometimes I use the element inspect from the browsers, I like Firebug for Mozilla, if I want to take a look in more details.

I am new to php as well, so often I check the forum for directions or to ask questions.

Thank you for your generous replies guys. :)

Sorry, I still have a few things to consider. Working with PHP seems so much different then regular programming languages in which those only need an IDE and compliler. So I take it as this.

Download apache for webserver. Download php 5.4 (stable) to be able to use php of course.

But do I need to download mysql?? I mean, I have already been provided a database made in mysql by someone.

I also want to ask the following:

If I already have a website made, and a mysql database prepared for it, do the above steps still work or are the steps different? What I mean is, if the website is already hosted on a payware webhoster with a custom made mysql database attached, how would go about writing PHP for it? Do you recommend ignoring the files hosted online but rather work with the source file of the website and database offline for the sake of PHP development?

Finally, do I write PHP codes directly into the HTML file of the website like javascript?

Thank you again for your generous replies,

Limiter

you can insert php code similar to HTML ,but the file extension must be .php

And another point is you shouldnot directly code into server.Take a backup of your code and develop in your local system.
Install MySQL,PHP or you can install wamp server which contains both along with apache server.

I would recommend that you duplicate the online files - offline. This is in case, you have to code php code that connect to the mysql database. There would be a trouble if you are disconnected to the database. Unless your code is unconnected to the database or the database is unnecessary.

Several people mentioned WAMP or XAMPP, but it wasn't really explained what the purpose of these is. They're essentially packages of Apache, MySQL, and PHP (+ more, but these are the main items we're interested in here) which will allow you to develop locally on your machine. You can then place your site documents in the appropriate folder (e.g., xampp\htdocs), turn on Apache and MySQL, and view your website locally on your machine by pointing your browser to http://localhost/.

As for putting your site live, you can then take this local copy and upload it to your hosting provider's server. If they already have MySQL and PHP installed (many paid hosting solutions these days do) you don't need to do anything else, just point your browser to your site's domain/IP.

When writing PHP code, oftentimes developers use a simple text editor program with syntax highlighting. I prefer Notepad++. There are other options that are more along the lines of an IDE, such as Aptana Studio (which I believe is built on Eclipse), but I personally don't use them. PHP usually goes into PHP files (.php among other extensions), and you can write it inline with HTML.

commented: Thanks for diving into details. :) +1
commented: good explanation +12

Thank you guys, I feel like I really have a grasp on what is going on now. :)

I have been provided a website created in .html that must read information from a MySql database that have also been custom created.

So from what I gather here so far, I will do the following:

1: Get WAMP
2: Place the HTML document of the website in the appropriate folder.
3: Write PHP codes and test it on my given database. (Hopefully this means I can get the website to display information from what the database (MySQL) says.)

Seems easy enough so far. About the part where PHP can be written in HTML, is it normally done in this way? I know javascript is though and IIM stated that PHP files must be in .php. So I fear that if I add PHP codes into .html and rename it to .php, I will mess up the website file.

Cheers,

Limiter

.php would still able to read your html codes. it's normal to do it, normally people mixed html and php codes in .php files.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.