#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Trying to display data from two related Mysql tables


    Hi All,

    I am experience web programmer in ASP.net and I have done this is ASP.net but I am trying to move to PHP well because it is easier to program.
    What I am trying to do and having trouble with is I have two tables one with suggestions that users can add and the users have the ability to rate and comment on these suggestions and of course I want to list add the ratings and comments under the suggestion. I know how to do this in ASP.net but I don't know how to do it in PHP could someone please help
    This is what I have already

    <?php
    require "Config.php";
    session_start();
    $pwdb = mysql_connect($dbhost,$dbuser,$dbpass) or die("Unable to connect to $db");
    mysql_select_db($db) or die("Unable to select $db");
    $result = mysql_query("SELECT Suggestions.SuggestID, Suggestions.user_id, Suggestions.Suggest_title, Suggestions.date_entered, Suggestions.Suggest_body, acct.name, Vote.voteuser_id, Vote.vote, Vote.comment, Vote.votedate_entered FROM Suggestions inner join acct on Suggestions.user_id=acct.ID inner join Vote on Suggestions.SuggestID=Vote.post_id");
    echo "<table border='0'>
    <tr>
    <th>ID</th>
    <th>User Name</th>
    <th>Title</th>
    <th>Date</th>
    <th>Suggestion</th>
    <th>Vote</th>
    </tr>";
    while($row = mysql_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>" . $row['SuggestID'] . "</td>";
    echo "<td>" . $row['name'] . "</td>";
    echo "<td>" . $row['Suggest_title'] . "</td>";
    echo "<td>" . $row['date_entered'] . "</td>";
    echo "<td>" . $row['Suggest_body'] . "</td>";
    echo "<td><a href='suggestion.php?suggestionID=$row[SuggestID]'>Vote</a></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td></td>";
    echo "<td></td>";
    echo "<td>" . $row['vote'] . "</td>";
    echo "<td>" . $row['comment'] . "</td>";
    echo "<td>" . $row['votedate_entered'] . "</td>";
    echo "<tr>";
    }
    echo "</table>";
    mysql_close($con);
    ?>
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,002
    Rep Power
    9398
    What's the current problem you're trying to solve, or code you're trying to write? How would you do it in ASP.NET?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by requinix
    What's the current problem you're trying to solve, or code you're trying to write? How would you do it in ASP.NET?
    the problem is I am not sure how to get this to work. The point of asp.net just to say I did there. My goal is to get thin to work in php because the is the direction I am going right now and with asp.net it was done in a nested datalist which is not an HTML markup

    ----suggestion----
    --------vote------
    --------vote----
    ----suggestion----
    --------vote----
    --------vote-----
    --------vote-----

    the vote table has a field for the suggest table and I want to list all the votes under the suggestion and then goto the next suggestion and list all the votes there

IMN logo majestic logo threadwatch logo seochat tools logo