Tag: PHP

  • PHP MySQL Count Rows

    So, you are looking for a simple way to return the number of entries returned from a database query.

    mysql_num_rows

    This command counts all the rows currently defined by the database query and returns this value.  The best way to use this command, is while saving it the a variable.

    Example

    (more…)

  • PHP assign contents of a script to a variable

    Say you would like to include the content of script in your code.  By passing the variable to the script and returning this value, you can create a truly dynamic entry for your code, without any duplication of effort.

    Here’s the breakdown:

    1. Use an output buffer
    2. Start the output buffer
    3. include the file with the passed variable
    4. store the buffered content in a variable
    5. stop the buffer.

    (more…)