Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I have a dynamic page and a user can create or view posts. As of right now all of the posts show, I want to organize my posts by categories. But once the user goes to the page all of the posts will show at first. But at the top will be a box where you can select "show all" "Category 1" "Cat 2" "cat 3" or "cat 4". Show all will be automatically checked once the user enters the page, but if they click a different box it will only show those posts with that particular category. Is this the right way to do this? and does anyone have and example or coding tutorials I could use, I have a bad/small experience with php.

my code:

<?php  
        //if(isset($_GET['message'])){ 
        //echo "<br/><b>".htmlspecialchars(strip_tags(stripslashes(trim($_GET['message']))))."!</b><br/>"; 
        //} 
        if(!isset($_GET["eventId"])){ 
        // $doQuery contains all rows which satisfied the query, but in our case it is only 1 row 
        // because we have no more than 1 page with same id 
        // mysql_fetch_array - a function which can be used to loop through rows in query result  
        // in this case we can use it without while loop because we need only 1 row 
        $result = mysql_fetch_array($doQuery); 
        echo "<h6>".$result["name"]."</h6><br/>"; 
        ?> 
        </div> 
    </div><!--title--> 
    </div> 
<div id="content"> 
    <div id="table"> 
    <p> 
    <?php  
    if(isset($_SESSION['username'])){ 
        echo "<a href=\"addEvent.php?page=$pageId\"><img class=\"button\" src=\"images/button1.png\"></a><br/><br/>"; 
    } 
    $query = "select * from events where page_id=$pageId order by id desc"; 
    $doQuery = mysql_query($query); 
    if(mysql_num_rows($doQuery)>0){ 
        echo "<div id=\"post\">"; 
        echo "<div id=\"head\"><h3></h3></div>"; 
        echo "<br/>"; 
        echo "<br/>"; 
        while($result = mysql_fetch_array($doQuery)){ 
        $query = "select Name, username from users where id=".$result["user_id"]; 
        $doTempQuery = mysql_query($query); 
        $resultTemp = mysql_fetch_array($doTempQuery); 
        $name = $resultTemp["Name"]; 
        $email = $resultTemp["username"]; 
        if($email==$_SESSION['username']){ 
        echo "<div id=\"single\">"; 
        echo "</div>"; 
        echo "<br/>"; 
        echo "<br/>"; 
        echo "<div id=\"element\">"; 
        echo "<div id=\"inner\">"; 
        echo "<div id=\"edit\"><a href=\"deleteEvent.php?event_id=".$result["id"]."&pageId=$pageId\">Delete</a> | <a href=\"editEvent.php?event_id=".$result["id"]."&pageId=$pageId\">Edit</a></div>"; 
    } 
        echo "<div id=\"words\"><h8>Created by:</h8>$name<br> <h8>Email:</h8>$email</div>"; //email 

        echo "<div id=\"first\">"; 
        echo "<div id=\"what\"></div><div id=\"whatbox\">".$result["what"]."</div>"; 
        echo "</div>"; 

        echo "<div id=\"second\">"; 
        echo "<div id=\"when\"></div><div id=\"whenbox\">".$result["when"]."</div>"; 
        echo "</div>"; 

        echo "<div id=\"third\">"; 
        echo "<div id=\"where\"></div><div id=\"wherebox\">".$result["where"]."</div>"; 
        echo "</div>"; 

        echo "<div id=\"fourth\">"; 
        echo "<div id=\"sponsor\"></div><div id=\"sponsorbox\">".$result["sponsored_by"]."</div>"; 
        echo "</div>"; 

        echo "<div id=\"fifth\">"; 
        echo "<div id=\"details\"></div><div id=\"detailsbox\">".$result["details"]."</div>"; 
        echo "</div>"; 
        echo "<br/>"; 
        echo "<br/>"; 
        echo "</div>"; 
        echo "</div>"; 

        } 
        echo "</table>"; 
        echo "</div>"; 
        echo "<br/>"; 
        echo "<br/>"; 
    } else echo "No events yet."; 
    } else echo "No posts yet."; 
share|improve this question
Code review is not the place to ask for help, it is the place to get reviewed the (working) code you currently have. This would be better on SO, but more than likely they wont like it there either as this is covered in detail through multiple tutorials online. But let me help you clean up what you do have with a bit of advice. If you have a bunch of HTML you need to print out, escape from PHP ?> and then start typing your HTML. If you have a small bit of PHP to add to a lot of HTML, escape the HTML momentarily <?php echo $var; ?> and echo it out. – mseancole Sep 12 '12 at 19:04

closed as off topic by mseancole, Jeff Vanzella, Corbin, Paul, Quentin Pradet Sep 17 '12 at 8:38

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.