2nd Web Development Tutorial : Basic Concept of PHP, HTML, MySQL, Javascript, CSS

As I mentioned in the previous post, basically, there are three main things to understand in web development.

  1. Server-side scripting (PHP, Python, Pearl, Java, C++, etc)
  2. Client-side scripting (HTML, Javascript, CSS, etc)
  3. Database (Oracle, MySQL, etc)

For server-side and database scripting, commonly, you only need to understand only one of the languages. For example, with a very simple understanding of PHP and MySQL, and a little bit of client-side scripting knowledge, you can already create a very powerful site.

As we can see in the picture above, Client Side is really in the client side, but developer must also create the code for them. This is because although we develop something in the server side, the server will process the code and send it to clients. One basic thought that we must consider is that server side script will convert itself to client side script based on how we create it to do so. So, users in the client side won’t be able to see our PHP script at all. What they see is just codes of HTML, CSS, Javascript, and other client side scripts. For instance, we create a code like this in our index.php page :

<?php
echo 'This is my beautiful website.';
?>

Whenever a user requested index.php page, the server is not going to send that code to client. Instead, PHP will convert it to client side code. In this case, the code above will convert to HTML code below.

As you can see, clients can only see HTML code, not the PHP code. They can only see other client side scripts such as javascript, CSS, and HTML. For those who wonder how to see raw HTML code as seen above, simply right click on any area in your browser, then click Inspect.

Now let’s dig in deeper into the collaboration of Server, Client, and Database scripting. Let’s create a simple PHP code below called simpleweb.php.

<!DOCTYPE html>
<html>
<head>
<style>
    table {
        width: 100%;
        border-collapse: collapse;
    }
    
    table, td, th {
        border: 1px solid black;
        padding: 5px;
    }
    
    th {text-align: left;}
</style>
<script>
  alert('Hey, JS is working here');
</script>
</head>
<body>

<?php
$con = mysqli_connect('localhost','root','','test');
if (!$con) {
    die('Could not connect: ' . mysqli_error($con));
}

mysqli_select_db($con,"test");
$sql="SELECT * FROM tb_user";
$result = mysqli_query($con,$sql);

echo "<table>
    <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
    <th>Hometown</th>
    <th>Job</th>
    </tr>";
    while($row = mysqli_fetch_array($result)) {
        echo "<tr>";
        echo "<td>" . $row['firstname'] . "</td>";
        echo "<td>" . $row['lastname'] . "</td>";
        echo "<td>" . $row['age'] . "</td>";
        echo "<td>" . $row['hometown'] . "</td>";
        echo "<td>" . $row['job'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
    mysqli_close($con);
?>
</body>
</html>

Code above contains all client side programming languages I mentioned earlier (HTML, Javascript, and CSS), and PHP and MySQL code. Let’s see how it looks like in the client side.

At first, because we added javascript in our code containing Alert function, Chrome interprets it as an alert to be shown first before showing other things. Let’s see the rest of the response it received after I clicked OK in the alert box.

From picture above, we can see that there is no more PHP or MySQL code at all. What wee see is just a bunch of HTML, Javascript, and CSS code based on how we code on PHP. The table is nicely styled in CSS, and the content is like being hard coded, although actually it is taken directly from MySQL database, which is very dynamic.

So that is a very simple understandings on how server, client, and database scripts works in web development. I recommend you to try yourself using my code above in order to understand it very well. After this, I will post another interesting topic to learn deeper about each individual languages. So, keep learning and don’t forget to code.

5,222 comments

  1. Aktiv Keto Reviews

    I know this if off topic but I’m looking into starting my own blog and was curious
    what all is needed to get setup? I’m assuming having a blog like
    yours would cost a pretty penny? I’m not very web smart so I’m not 100% positive.
    Any tips or advice would be greatly appreciated. Cheers

    my blog Aktiv Keto Reviews

  2. https://www.yelp.com/user_details?userid=G_AOhA8uadztSolIbPm4Hw

    Definitely consider that which you said. Your
    favorite justification appeared to be at the internet the easiest thing to take into account
    of. I say to you, I certainly get irked while people consider issues that they plainly do not
    recognise about. You controlled to hit the nail upon the top and defined out the
    whole thing without having side-effects , people could take a signal.
    Will likely be again to get more. Thank you

  3. DangoBuds Earbuds

    I don’t even know how I finished up here, however I assumed this put up used
    to be great. I do not realize who you’re however definitely you are
    going to a famous blogger for those who are not already.

    Cheers!

    My website :: DangoBuds Earbuds

  4. xml

    I see something truly special in this website.

    my website – xml

  5. porn

    I’ve read several excellent stuff here. Certainly value bookmarking for revisiting.

    I surprise how much effort you set to make any such magnificent informative website.

    Here is my blog post … porn

  6. http://advertising-services.org/blogs/viewstory/8331

    Good – I should certainly pronounce, impressed with your web
    site. I had no trouble navigating through all tabs as well as related information ended up being truly easy to do to access.
    I recently found what I hoped for before you know it in the least.
    Reasonably unusual. Is likely to appreciate it for those who add
    forums or something, website theme . a tones way for your customer to communicate.
    Nice task.

    Feel free to surf to my web-site … http://advertising-services.org/blogs/viewstory/8331

  7. Full Releaf CBD Reviews

    Excellent site. A lot of helpful information here. I’m sending it to some
    buddies ans additionally sharing in delicious.
    And of course, thanks to your sweat!

    my web page – Full Releaf CBD Reviews

  8. Full Releaf CBD Review

    Ahaa, its nice dialogue regarding this piece of writing here at this web site, I have
    read all that, so now me also commenting at this place.

    Feel free to surf to my webpage :: Full Releaf CBD Review

  9. hoodksa

    We stumbled over here different web address and thought I may
    as well check things out. I like what I see so i am just
    following you. Look forward to looking into your web page repeatedly.

  10. Myrna

    This paragraph will help the internet visitors for creating new webpage or even a weblog from start to
    end.

  11. Rowena

    Very rapidly this web site will be famous amid all blogging and site-building viewers, due to
    it’s fastidious content

  12. homepage

    An immpressive share! I’ve just forwarded this
    onto a co-worker who has been doing a little
    homework on this. And he in fact bought me dinner duee to
    the fact that I found it for him… lol. So let me reword
    this…. Thanks forr the meal!! But yeah, thnanx for
    spending the time to discuss this mater here on your web page.

    homepage

  13. solar hybrid catamaran

    My brother recommended I would possibly like this web site.
    He was entirely right. This publish truly made my day.
    You cann’t imagine just how a lot time I had spent
    for this information! Thank you!

  14. education

    Hi there! I simply want to give you a big thumbs
    up for the excellent information you have here on this post.

    I will be coming back to your web site for more
    soon.

  15. lawn care Omaha

    Generally I don’t read article on blogs, but I wish to say that this
    write-up very pressured me to check out and do it! Your writing style has been surprised me.
    Thanks, very nice post.

  16. nearest marijuana dispensary

    Ні there, There’s no doubt that your site could possibly
    be having internet browsеr compatibility іssսes.
    Whenever I take a look at your ƅlogg in Safari, it looҝs fine bbut when opening in I.E., it haas some ߋverlapping issues.

    I simply wanted to give yoou a quick heaads up! Besides tһat,
    fаntastic weЬsite!

    My webpage; nearest marijuana dispensary

  17. Mahalia

    you are in reality a just right webmaster. The web site loading velocity is amazing.
    It sort of feels that you’re doing any unique
    trick. Also, The contents are masterwork.
    you’ve performed a fantastic task on this topic!

  18. helion-ltd.ru

    I’m really loving the theme/design of your weblog. Do you ever run into any browser compatibility problems?
    A few of my blog readers have complained about my
    blog not working correctly in Explorer but looks great in Firefox.
    Do you have any recommendations to help fix this problem?

Leave a Reply

Your email address will not be published. Required fields are marked *