This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Join Tables Question


  1. rscott7706
    Member

    For some reason, the following query works fine (QUERY 1), but the one further down (QUERY 2) that attempts to join tables does not.

    I know questions here should be about Machform, but it would solve a lot of problems for me if I can get the "join tables" concept down pat.

    I left out username and password from code.

    Here is a link to the one that works:

    https://communityrecoveryteam.org/volunteer%20form/apForm1_List.php

    QUERY 1

    <?php
    echo "<font face=\"verdana\">";
    echo "
    ";
    $db = mysql_connect("localhost", "", "");
    mysql_select_db("crtsdorg_userforms");

    $query = "SELECT * FROM ap_form_1 ORDER BY id desc";

    $result = mysql_query($query) or die(mysql_error());
    echo "<font face=\"arial\">";
    while($row = mysql_fetch_array($result)){
    echo "
    ID: ";
    echo $row['id'];
    echo "  Date Volunteered: ";
    echo $row['date_created'];
    }
    ?>

    QUERY 2

    <?php
    echo "<font face=\"verdana\">";
    echo "
    ";
    $db = mysql_connect("localhost", "", "");
    mysql_select_db("crtsdorg_userforms");

    $query = "SELECT id, date_created
    FROM ap_form_1, ap_element_options
    WHERE ap_form_1.id = ap_element_options.form_id
    ORDER BY date_created DESC;

    $result = mysql_query($query) or die(mysql_error());
    echo "<font face=\"arial\">";
    while($row = mysql_fetch_array($result)){
    echo "
    ID: ";
    echo $row['id'];
    echo "  Date Volunteered: ";
    echo $row['date_created'];
    }
    ?>

    Here is the error:
    Parse error: syntax error, unexpected T_STRING in /home6/crtsdorg/public_html/volunteer form/apForm1_List2.php on line 13

    Posted 14 years ago #
  2. yuniar

    I think you forgot to close the double quote for your query, it should be like this:

    $query = "SELECT id, date_created
    FROM ap_form_1, ap_element_options
    WHERE ap_form_1.id = ap_element_options.form_id
    ORDER BY date_created DESC";

    MachForm Founder

    Posted 14 years ago #

RSS feed for this topic

Reply