Hello and Merry Christmas to all!

Can anyone explain the correct behavior of a web application: what PHP is used for, what JavaScript is used for?

For now, I want to make a simple page with radio buttons, drop down lists and text areas. Some will have data from the database, and others will have input that data will be saved into the database.

My understanding is that I can use PHP for database operations and JavaScript for manipulating existing HTML objects. Can anyone confirm is this is correct and/or go into more detail?

Thank you.

JavaScript runs client-side, can modify the HTML page, but can also communicate with a server (e.g. to retrieve fresh data).

PHP runs server-side and can do database operations, but also a lot more.

Thanks.

How should I populate the HTML with data fetched by PHP? is the following correct:

...
while($row=mysql_fetch_array($result)){
    echo "</td><td>";
    echo $row['some_db_column'];
    echo "</td><td>";
}

Basically, although it may output invalid tags. Personally, I'd like to use a template engine (Smarty, RainTpl) for this.

Member Avatar for diafol

As Prtaeas states, templaters should make things easier but they're not for everybody. Your code could spit out a ridiculously long table. Row tags need to be inserted from time to time to keep it a sensible width

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.