0

I'm having a problem trying to work out the best way of doing this. I'm creating a template/review system which allows users to fill in a template and then search on reviews done. Each review is marked on multiple sections which I need to display.

My problem is that I need to list each separate review and it's section in the 'slidingDiv'. Currently this overwrites the $htm variable so each review & it's respective sections is exactly the same when displayed (each done using a different template therefore should be different). I tried using arrays but these were being overwritten. Visually the idea is to have a table which displays each Review and then when they select the Review the 'slidingDiv' shows the Sections of that Review below the Review table.

I realise I'm quite far off the solution but this was the closest I've been getting. Currently I have the below:

    if (isset($reviews)) {
    include ("templates/default/pheader.php");
    echo "<p>Search results displayed below:</p>";
    echo "<table id=table-search>";
    echo "<tr>";
    echo "<th>ECR</th><th>Consultant</th><th>Reviewer</th><th>Template</th><th>Date</th>";
    echo "</tr>";

    foreach ($reviews as $review) {
        $ecr = $review->get_ecr();
        $member = $review->get_team_member();
        $user = $review->get_user();
        $user_name = $user->get_name();
        $template = $review->get_template();
        $template_name = $template->get_name();
        $member_name = $member->get_name();
        $timestamp = $review->get_timestamp();

        echo "<tr>";
        echo "<td>";
        echo "<a href=\"#\" class=\"show_hide\">$ecr</a>";
        echo "</td>";
        echo "<td>";
        echo "$member_name";
        echo "</td>";
        echo "<td>";
        echo "$user_name";
        echo "</td>";
        echo "<td>";
        echo "$template_name";
        echo "</td>";
        echo "<td>";
        echo "$timestamp";
        echo "</td>";
        echo "</tr>";

        foreach ($review->get_sections() as $section) {
            $section_name = $section->get_name();
            $section_total = $section->get_total();
            $section_mark = $section->get_mark();
            $section_pass = $section->get_pass();
            if ($section_pass == 1) {
                $section_pass = "<font color = \"green\">PASS</font>";
            } else {
                $section_pass = "<font color = \"red\">FAIL</font>";
            }
            $htm .= "<tr><td>$section_name</td>";
            $htm .= "<td>$section_total / $section_mark marks</td>";
            $htm .= "<td>$section_pass</td></tr>";
        }
    }
    echo "</table>";
    echo "<div class=\"slidingDiv\">";
    echo "<table>";
    //List each section per Review
    echo "</table>";
    echo "<p><a href=\"#\" class=\"show_hide\">Hide</a></div></p>";
    echo "<p><a href=\"search.php\">Search Again</a></p>";
}
3
  • 1
    why would you write echo $template_name as echo "$template_name"; Commented May 29, 2013 at 10:34
  • No real reason other than I did have other values in there and haven't tidied up yet. Commented May 29, 2013 at 10:36
  • Use a templating engine... Commented May 14, 2014 at 14:30

1 Answer 1

1

Looking at the code, I'd be tempted to create just the html first with sample content to get the feel of the page and the final result you're aiming for. Then, once you're happy, add the php to the first foreach block and test you're getting the right information using var_dumps or print_r commands.

Once you're happy, move on to the second foreach block, testing as you go.

Trying to do the code and html combined in this way will always be a bit daunting, working in bite size chunks like this enables you to be more confident of the end result.

I hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

That's not really the problem but thanks. I know how it's going to look it's just the logistics of getting the right information out. I think I'm going to have to use Ajax here and pass a current Review and then display the information that way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.