Announcement

Collapse
No announcement yet.

Help with php mysql queries

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with php mysql queries

    I am somewhat of a php newbie especially when it comes to connecting to a mysql database and doing queries than using the information from the queries.

    Here's what I have setup so far.
    The php file looks likes this.
    PHP Code:
    <?php
    require_once('./inclu/vars.php');
    include(
    './inclu/main.inc');
    ?>
    the inc file is mainly html so I have my index.php loads it's html from that and ideally it loads all the variables/functions from the vars.php file and I call them in the main.inc file.

    Here's what my vars.php file looks like
    PHP Code:
    <?php
    $host 
    "localhost";
    $db "forum";
    $user "";
    $pass "";
    $dbconnect mysql_connect($host$user$pass);
                 
    mysql_select_db($db$dbconnect);
    $requiretest "testing to see if the require worked properly and the variables are being passed on"

    ?>
    Also I tested to see if everything was being passed on right by putting this line in the main.inc file <?php print $requiretest; ?> and it worked.

    Anyways what I don't really know how setup two mysql queries and than use the information in main.inc

    It seems like the information I need is divided into two tables the thread table which has the forumid field (I only want to grab posts from forumid = 11), title and postusername fields.

    Than there's the post table which I am guessing I would need to grab stuff from threadid and pagetext fields.

    Essentially what I want to do is grab the most recent post in my news forum which has the id of 11 and grab a short excerpt from it.

    than for the other query how would I grab the titles of the most recent 10 posts in the same forum just minus the most recent since I already grabbed that.

    Thanks in advanced for any help.
    Xbox Live teams.com
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X