Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 26

Thread: PHP Code help please

  1. #11
    Join Date
    Jun 2003
    Location
    Launceston, Tasmania
    Posts
    12,347
    Total Downloaded
    0
    that looks like a much better start than what I had.

    I'll give it a whirl and let you all know how I go.
    1994 Discovery TDi
    2004 Discovery 2 TD5
    2010 Discovery 4 TDV6
    1961, Series 2 Ambulance. 108-098 - Eden

    Registry of Ex Military Land Rovers Mem. 129
    Defence Transport Heritage Tasmania Member

  2. #12
    Join Date
    Jun 2003
    Location
    Launceston, Tasmania
    Posts
    12,347
    Total Downloaded
    0
    ok, I am getting a 500 internal server error, so most likely i've got a syntax problem.

    The code as it stands (the trial is online at remlrchassis2 and 3)

    //connect to the database
    $dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");
    //select a database to work with
    $selected = mysql_select_db($dbname,$dbhandle) or die("Could not select examples");
    $result = mysql_query("SELECT membership.membership_no, membership.name_public, membership.state"
    . " FROM membership ");
    //fetch tha data from the database
    echo "<center><table width=600 border=0 cellspacing=8 cellpadding=0>";
    while ($row = mysql_fetch_array($result)) {echo "
    <tr bgcolor=#CCCCCC>
    <td colspan=4>REMLR No. ".$row{'membership_no'}."
    </td>
    </TR>
    <TR>
    <td colspan=4>".$row{'name_public'}."
    </td>
    </TR>
    $result2 = mysql_query("SELECT arn.ARN, census.census_short, arn.vehicle_name"
    . " FROM arn INNER JOIN"
    . " mem2arn ON arn.ARN = mem2arn.ARN INNER JOIN"
    . " census ON arn.census = census.census RIGHT OUTER JOIN"
    . " membership ON mem2arn.membership_no = membership.membership_no"
    . " WHERE mem2arn.membership_no = $row{membership_no}"
    . " ORDER BY arn.ARN");
    while ($row = mysql_fetch_array($result2)) {echo "
    <tr>
    <td width=150>&nbsp;
    </td>
    <td>".$row{'ARN'}."
    </td>
    <td> -
    </td>
    <td> ".$row{'census_short'}. "
    </td>
    </tr>";
    }
    <TR>
    <td colspan=4 align=right>".$row{'state'}."
    </td>
    </TR>";
    }
    echo "</table></center>";
    ?>
    1994 Discovery TDi
    2004 Discovery 2 TD5
    2010 Discovery 4 TDV6
    1961, Series 2 Ambulance. 108-098 - Eden

    Registry of Ex Military Land Rovers Mem. 129
    Defence Transport Heritage Tasmania Member

  3. #13
    Join Date
    Apr 2009
    Location
    Cairns, QLD
    Posts
    115
    Total Downloaded
    0
    Yeah missing " and . i've added them in in red (hopefully all of them)

    Quote Originally Posted by Phoenix View Post
    ok, I am getting a 500 internal server error, so most likely i've got a syntax problem.

    The code as it stands (the trial is online at remlrchassis2 and 3)

    //connect to the database
    $dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");
    //select a database to work with
    $selected = mysql_select_db($dbname,$dbhandle) or die("Could not select examples");
    $result = mysql_query("SELECT membership.membership_no, membership.name_public, membership.state"
    . " FROM membership ");
    //fetch tha data from the database
    echo "<center><table width=600 border=0 cellspacing=8 cellpadding=0>";
    while ($row = mysql_fetch_array($result)) {echo "
    <tr bgcolor=#CCCCCC>
    <td colspan=4>REMLR No. ".$row{'membership_no'}."
    </td>
    </TR>
    <TR>
    <td colspan=4>".$row{'name_public'}."
    </td>
    </TR>";
    $result2 = mysql_query("SELECT arn.ARN, census.census_short, arn.vehicle_name"
    . " FROM arn INNER JOIN"
    . " mem2arn ON arn.ARN = mem2arn.ARN INNER JOIN"
    . " census ON arn.census = census.census RIGHT OUTER JOIN"
    . " membership ON mem2arn.membership_no = membership.membership_no"
    . " WHERE mem2arn.membership_no = $row{membership_no}"
    . " ORDER BY arn.ARN");
    while ($row = mysql_fetch_array($result2)) {echo "
    <tr>
    <td width=150>&nbsp;
    </td>
    <td>".$row{'ARN'}."
    </td>
    <td> -
    </td>
    <td> ".$row{'census_short'}. "
    </td>
    </tr>";
    }
    echo "
    <TR>
    <td colspan=4 align=right>".$row{'state'}."
    </td>
    </TR>";
    }
    echo "</table></center>";
    ?>

    Those changes should fix it

  4. #14
    Join Date
    Apr 2009
    Location
    Cairns, QLD
    Posts
    115
    Total Downloaded
    0
    btw these changes (in red again) also need to be made otherwise you will change the value of $row and not be able to write $row(state)


    Yeah missing " and . i've added them in in red (hopefully all of them)

    Quote Originally Posted by Phoenix View Post
    ok, I am getting a 500 internal server error, so most likely i've got a syntax problem.

    The code as it stands (the trial is online at remlrchassis2 and 3)

    //connect to the database
    $dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");
    //select a database to work with
    $selected = mysql_select_db($dbname,$dbhandle) or die("Could not select examples");
    $result = mysql_query("SELECT membership.membership_no, membership.name_public, membership.state"
    . " FROM membership ");
    //fetch tha data from the database
    echo "<center><table width=600 border=0 cellspacing=8 cellpadding=0>";
    while ($row = mysql_fetch_array($result)) {echo "
    <tr bgcolor=#CCCCCC>
    <td colspan=4>REMLR No. ".$row{'membership_no'}."
    </td>
    </TR>
    <TR>
    <td colspan=4>".$row{'name_public'}."
    </td>
    </TR>"
    $result2 = mysql_query("SELECT arn.ARN, census.census_short, arn.vehicle_name"
    . " FROM arn INNER JOIN"
    . " mem2arn ON arn.ARN = mem2arn.ARN INNER JOIN"
    . " census ON arn.census = census.census RIGHT OUTER JOIN"
    . " membership ON mem2arn.membership_no = membership.membership_no"
    . " WHERE mem2arn.membership_no = $row{membership_no}"
    . " ORDER BY arn.ARN");
    while ($secondrow = mysql_fetch_array($result2)) {echo "
    <tr>
    <td width=150>&nbsp;
    </td>
    <td>".$secondrow{'ARN'}."
    </td>
    <td> -
    </td>
    <td> ".$secondrow{'census_short'}. "
    </td>
    </tr>";
    }
    <TR>
    <td colspan=4 align=right>".$row{'state'}."
    </td>
    </TR>";
    }
    echo "</table></center>";
    ?>

  5. #15
    Join Date
    Jun 2003
    Location
    Launceston, Tasmania
    Posts
    12,347
    Total Downloaded
    0
    Josh aka sean, many thanks for your help with this

    Ok, the page loads correctly now

    Member summary list - REMLR

    Names load up

    but no vehicles

    Current code

    //connect to the database
    $dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");
    //select a database to work with
    $selected = mysql_select_db($dbname,$dbhandle) or die("Could not select examples");
    $result = mysql_query("SELECT membership.membership_no, membership.name_public, membership.state"
    . " FROM membership ");
    //fetch tha data from the database
    echo "<center><table width=600 border=0 cellspacing=8 cellpadding=0>";
    while ($row = mysql_fetch_array($result)) {echo "
    <tr bgcolor=#CCCCCC>
    <td colspan=4>REMLR No. ".$row{'membership_no'}."
    </td>
    </TR>
    <TR>
    <td colspan=4>".$row{'name_public'}."
    </td>
    </TR>";
    $result2 = mysql_query("SELECT arn.ARN, census.census_short, arn.vehicle_name"
    . " FROM arn INNER JOIN"
    . " mem2arn ON arn.ARN = mem2arn.ARN INNER JOIN"
    . " census ON arn.census = census.census RIGHT OUTER JOIN"
    . " membership ON mem2arn.membership_no = membership.membership_no"
    . " WHERE mem2arn.membership_no = $row{membership_no}"
    . " ORDER BY arn.ARN");
    while ($secondrow = mysql_fetch_array($result2)) {echo "
    <tr>
    <td width=150>&nbsp;
    </td>
    <td>".$secondrow{'ARN'}."
    </td>
    <td> -
    </td>
    <td> ".$secondrow{'census_short'}. "
    </td>
    </tr>";
    }
    echo"
    <TR>
    <td colspan=4 align=right>".$row{'state'}."
    </td>
    </TR>";
    }
    echo "</table></center>";
    ?>
    1994 Discovery TDi
    2004 Discovery 2 TD5
    2010 Discovery 4 TDV6
    1961, Series 2 Ambulance. 108-098 - Eden

    Registry of Ex Military Land Rovers Mem. 129
    Defence Transport Heritage Tasmania Member

  6. #16
    Join Date
    Apr 2009
    Location
    Cairns, QLD
    Posts
    115
    Total Downloaded
    0
    Hi no probs for the help. Can you add the line of code in red just to check if results are being returned by the second query.

    Quote Originally Posted by Phoenix View Post
    Josh aka sean, many thanks for your help with this

    Ok, the page loads correctly now

    Member summary list - REMLR

    Names load up

    but no vehicles

    Current code

    //connect to the database
    $dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");
    //select a database to work with
    $selected = mysql_select_db($dbname,$dbhandle) or die("Could not select examples");
    $result = mysql_query("SELECT membership.membership_no, membership.name_public, membership.state"
    . " FROM membership ");
    //fetch tha data from the database
    echo "<center><table width=600 border=0 cellspacing=8 cellpadding=0>";
    while ($row = mysql_fetch_array($result)) {echo "
    <tr bgcolor=#CCCCCC>
    <td colspan=4>REMLR No. ".$row{'membership_no'}."
    </td>
    </TR>
    <TR>
    <td colspan=4>".$row{'name_public'}."
    </td>
    </TR>";
    $result2 = mysql_query("SELECT arn.ARN, census.census_short, arn.vehicle_name"
    . " FROM arn INNER JOIN"
    . " mem2arn ON arn.ARN = mem2arn.ARN INNER JOIN"
    . " census ON arn.census = census.census RIGHT OUTER JOIN"
    . " membership ON mem2arn.membership_no = membership.membership_no"
    . " WHERE mem2arn.membership_no = $row{membership_no}"
    . " ORDER BY arn.ARN");

    echo "number of rows " . mysql_num_rows($result2);

    while ($secondrow = mysql_fetch_array($result2)) {echo "
    <tr>
    <td width=150>&nbsp;
    </td>
    <td>".$secondrow{'ARN'}."
    </td>
    <td> -
    </td>
    <td> ".$secondrow{'census_short'}. "
    </td>
    </tr>";
    }
    echo"
    <TR>
    <td colspan=4 align=right>".$row{'state'}."
    </td>
    </TR>";
    }
    echo "</table></center>";
    ?>

  7. #17
    Join Date
    Jun 2003
    Location
    Launceston, Tasmania
    Posts
    12,347
    Total Downloaded
    0
    done

    Member summary list - REMLR

    lots of number of rows, but that's it.
    1994 Discovery TDi
    2004 Discovery 2 TD5
    2010 Discovery 4 TDV6
    1961, Series 2 Ambulance. 108-098 - Eden

    Registry of Ex Military Land Rovers Mem. 129
    Defence Transport Heritage Tasmania Member

  8. #18
    Join Date
    Apr 2009
    Location
    Cairns, QLD
    Posts
    115
    Total Downloaded
    0
    Lol yeah sorry put the code in the wrong spot. 2 Thing this time 1st one is to put the code in the right spot and second is a change to the second query as a test so keep the original sql for it.


    //connect to the database
    $dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");
    //select a database to work with
    $selected = mysql_select_db($dbname,$dbhandle) or die("Could not select examples");
    $result = mysql_query("SELECT membership.membership_no, membership.name_public, membership.state"
    . " FROM membership ");
    //fetch tha data from the database
    echo "<center><table width=600 border=0 cellspacing=8 cellpadding=0>";
    while ($row = mysql_fetch_array($result)) {echo "
    <tr bgcolor=#CCCCCC>
    <td colspan=4>REMLR No. ".$row{'membership_no'}."
    </td>
    </TR>
    <TR>
    <td colspan=4>".$row{'name_public'}."
    </td>
    </TR>";
    $result2 = mysql_query("SELECT arn.ARN, arn.vehicle_name"
    . " FROM arn, mem2arn.membership
    . " WHERE mem2arn.membership_no = $row{membership_no}"
    . " AND mem2arn.ARN = arn.ARN"
    . " ORDER BY arn.ARN");




    while ($secondrow = mysql_fetch_array($result2)) {echo "
    <tr>
    <td width=150>&nbsp;
    </td>
    <td>".$secondrow{'ARN'}."
    </td>
    <td> -
    </td>
    <td> ".$secondrow{'census_short'}. "
    </td>
    </tr>";
    }
    echo"
    <TR>
    <td colspan=4 align=right>".$row{'state'}." . "number of rows " . mysql_num_rows($result2);
    </td>
    </TR>";
    }
    echo "</table></center>";
    ?>

  9. #19
    Join Date
    Jun 2003
    Location
    Launceston, Tasmania
    Posts
    12,347
    Total Downloaded
    0
    Mmm, no worky....

    //connect to the database
    $dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");
    //select a database to work with
    $selected = mysql_select_db($dbname,$dbhandle) or die("Could not select examples");
    $result = mysql_query("SELECT membership.membership_no, membership.name_public, membership.state"
    . " FROM membership ");
    //fetch tha data from the database
    echo "<center><table width=600 border=0 cellspacing=8 cellpadding=0>";
    while ($row = mysql_fetch_array($result)) {echo "
    <tr bgcolor=#CCCCCC>
    <td colspan=4>REMLR No. ".$row{'membership_no'}."
    </td>
    </TR>
    <TR>
    <td colspan=4>".$row{'name_public'}."
    </td>
    </TR>";
    $result2 = mysql_query("SELECT arn.ARN, arn.vehicle_name"
    . " FROM arn, mem2arn.membership
    . " WHERE mem2arn.membership_no = $row{membership_no}"
    . " AND mem2arn.ARN = arn.ARN"
    . " ORDER BY arn.ARN");
    while ($secondrow = mysql_fetch_array($result2)) {echo "
    <tr>
    <td width=150>&nbsp;
    </td>
    <td>".$secondrow{'ARN'}."
    </td>
    <td> -
    </td>
    <td> ".$secondrow{'census_short'}. "
    </td>
    </tr>";
    }
    echo"
    <TR>
    <td colspan=4 align=right>".$row{'state'}.". "number of rows " . mysql_num_rows($result2);
    </td>
    </TR>";
    }
    echo "</table></center>";
    ?>
    1994 Discovery TDi
    2004 Discovery 2 TD5
    2010 Discovery 4 TDV6
    1961, Series 2 Ambulance. 108-098 - Eden

    Registry of Ex Military Land Rovers Mem. 129
    Defence Transport Heritage Tasmania Member

  10. #20
    Join Date
    Apr 2009
    Location
    Cairns, QLD
    Posts
    115
    Total Downloaded
    0
    Yeah sorry try the updated red part (silly " again haha)

    Quote Originally Posted by Phoenix View Post
    Mmm, no worky....

    //connect to the database
    $dbhandle = mysql_connect($hostname, $username, $password)or die("Unable to connect to MySQL");
    //select a database to work with
    $selected = mysql_select_db($dbname,$dbhandle) or die("Could not select examples");
    $result = mysql_query("SELECT membership.membership_no, membership.name_public, membership.state"
    . " FROM membership ");
    //fetch tha data from the database
    echo "<center><table width=600 border=0 cellspacing=8 cellpadding=0>";
    while ($row = mysql_fetch_array($result)) {echo "
    <tr bgcolor=#CCCCCC>
    <td colspan=4>REMLR No. ".$row{'membership_no'}."
    </td>
    </TR>
    <TR>
    <td colspan=4>".$row{'name_public'}."
    </td>
    </TR>";
    $result2 = mysql_query("SELECT arn.ARN, arn.vehicle_name"
    . " FROM arn, mem2arn.membership
    . " WHERE mem2arn.membership_no = $row{membership_no}"
    . " AND mem2arn.ARN = arn.ARN"
    . " ORDER BY arn.ARN");
    while ($secondrow = mysql_fetch_array($result2)) {echo "
    <tr>
    <td width=150>&nbsp;
    </td>
    <td>".$secondrow{'ARN'}."
    </td>
    <td> -
    </td>
    <td> ".$secondrow{'census_short'}. "
    </td>
    </tr>";
    }
    echo"
    <TR>
    <td colspan=4 align=right>".$row{'state'}. " number of rows " . mysql_num_rows($result2) . "
    </td>
    </TR>";
    }
    echo "</table></center>";
    ?>

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search AULRO.com ONLY!
Search All the Web!