Jump to content

KenBrace

Active Members
  • Posts

    58
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by KenBrace

  1. I have a deep interest in philosophy, rational thinking, science, and topics of that nature. I've spent many a day in deep thought on such issues. To me it is more than a hobby though. More of a way of a life.

     

    I also have an interest in programming obviously.

  2. I'm having a hard time figuring out the logic for creating a private messaging system that allows for more than 2 participants.

     

    What kind of database setup could I use to do this?

     

    I don't want to have a table with field for "user1", "user2", "user3", etc. because it strikes me as terribly inefficient and just messed up. How can I store the users of a conversation?

     

    Maybe have a table for conversations, messages, and participants? Then all the users inside the participants table that are filed under the specific conversation ID are allowed to access? Would there be a way to do it with only two tables?

     

    What do you think is the most efficient way to accomplish this task?

  3. If you want to learn web design the four key languages are HTML, CSS, PHP, and Javascript. You will also want to learn a bit about MySQL and how to work with it using PHP. Start with HTML and CSS. Learn to do the designing. Once you have that down start learning JS and PHP. Javascript is used primarily to manipulate HTML and CSS dynamically. You can use it to change an element's color by clicking a button or creating a live chat box. But you need to learn how to create with HTML and CSS before you start learning how to manipulate it via user input with JS. PHP is used for security, server side actions, and database management. It's what you use to store a new user it a database upon registration or header people away from pages they aren't supposed to access. People can change your HTML, CSS, & Javascript (anything client side) but they can't mess with your PHP because it's server side. This is why it is used for security.

     

    Anyway just a basic overview. Hope that helps! :)

  4. Great thanks, added the code tags in there.

     

    So what's the advantage of doing it this way?

     

    There's not really a specific advantage of doing it this way vs using jQuery. It's the original way I learned it though so I tend to use it a lot since it's what I'm used to. It's also good just see exactly what's really going on when you use jQuery. A behind the scenes if you will. It's also good to know in case you don't have access to jQuery for some reason.

  5. This tutorial will give a basic overview of how to retrieve information from a MySQL database.

     

    Let's say you have a database table entitled "users".

     

    This table has five fields:

     

    1. ID

    2. Username

    3. Email

    4. Password

    5. Gender

     

    There is an entry in this table with the following values:

     

    1. 1

    2. Johnson

    3. john_d@gmail.com

    4. df6dd8d8f7df8dd8f7d8f7d8fdf7df6d (encrypted password)

    5. Male

     

    Let's further suggest that you wish to retrieve this user and his information from the database to use it in some way (maybe display on his profile or send him an email).

     

    This is how you would go about doing it.

     

    PHP File

    <?php
     
    include_once("conn.php"); //include your database connection file
     
    $user = $_GET['user']; //retrieve the name of the user you wish to search via the get method. However you can get the username any way you like. I'm just doing it this way for the tutorial.
     
    $fetch_user = "SELECT * FROM users WHERE username='$user'"; //this var holds the command for fetching all fields from the 'users' table where the username is equal to the '$user' variable
     
    $query_user = mysqli_query($conn, $fetch_user); //initiate the query and specify both the connection and command
     
    if(!$query_user){ //check for an error with the query and echo error message if it fails
    echo "There was an error retrieving the user information!";
    exit();
    }
     
    ?>
    
  6. This is a basic tutorial on how to retrieve information from a php parser using Ajax without jQuery.

     

    This is very useful when you wish to check if a user exists, check for live chat messages, etc.

     

    Javascript

    <script>
    
    function send(){
    var hr = new XMLHttpRequest(); //this variable represents your ajax request
    var url = "parser.php"; //the url to your php parser
    hr.open("POST", url, true); //initiate the ajax request
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //set the request header
    hr.onreadystatechange = function(){
    if(hr.readyState == 4 && hr..status == 200){ //this code checks whether or not the request has fully processed and returned valid
    var text = hr.responseText; //this is the text sent back from the php file
    alert(text); //you can do whatever you wish with the response text
    }
    }
    hr.send();
    }
    
    </script>

    PHP (short example)

    <?php
    
    echo "this text will be retrieved using Ajax";
    
    ?>
×
×
  • Create New...