1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

PHP/HTML Help 2

Discussion in 'BBS Hangout' started by Lil Pun, Oct 13, 2011.

  1. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    OK, I am working on a tracker so that people can login and tell if they have met certain requirements or not. I've got basic text output looking OK but I'd like to do something like:

    [​IMG]

    I want a table like this to show for everybody who logs in regardless whether they have taken a course or not. If they have met any of the conditions a check mark image would show up and if they haven't met the condition, an x mark would show up.

    I've tried to build it myself with no luck at all. I've tried to Google to see if I could find any type of template to build off of but have not found anything yet. Do any ClutchFans want to share some sample code so I can build off of it?
     
    #1 Lil Pun, Oct 13, 2011
    Last edited: Oct 13, 2011
  2. SwoLy-D

    SwoLy-D Member

    Joined:
    Jul 20, 2001
    Messages:
    37,619
    Likes Received:
    1,460
    I think it might help if you just start writing down the decision tree through which your programming would eventually have to go. Don't focus on the PHP syntax, language, or programming... right now make a top-down scheme or flowchart (even on paper, written, without using software) of what your programming would decide, based on the database, known details, etc.

    Here is a top-down example:
    [​IMG]

    I think you're trying to RUN a marathon here without even knowing how long it is. Take it slowly, man. :cool:
     
  3. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    Swoly,

    Thanks for the reply. I have actually done that, I took advice from you on my other PHP thread. :) I have my code and it is giving me output, I'd just like to fancy it up a bit. I know what I want and how I want it to work, just not sure how to code it. :(
     
  4. SwoLy-D

    SwoLy-D Member

    Joined:
    Jul 20, 2001
    Messages:
    37,619
    Likes Received:
    1,460
    What's the piece that's not working, or what are you coding that's not coming out the way you intended it to come out? :confused:

    Are you getting a different character than the one you want, or are you just looking to see what code writes out different output?

    Code:
    if (field_which_checks_class contains flag_saying_yes) { write_code_with_checkbox }
    else [do_nothing]
    Also, don't report NOTHING if they have taken NOTHING. Only report SOMETHING when they have taken SOMETHING. :cool:

    Sometimes you may need to step AWAY from the programming a bit, and think about writing less code to get what you want. It doesn't always have to be pretty, though. Just make sure the functionality is there before you write it all pretty.
     
  5. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    I'd just like it to be in a table similar to what I posted above. I'm not actually having trouble getting the code to work just want the output to look like that so I was hoping to get something to build off of.
     
  6. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    I'm sort of stuck right now.

    Here is my code:

    Code:
    if ($crsecode == "ENG1003" or $crsecode == "ENG1013") 
    		   {
    		   
    		   echo "<b>Communications segment consists of Composition I (ENG 1003) AND Composition II (ENG 1013)</b><p />";
    		   echo "Subject ".$subj." Course: ".$course.": <span style='color:black;font-weight:bold'>".$crsegrade."</span><p />";
    		   
    		  }
    It is working but what I actually want is to tell the user if they meet one or both of the variables listed.

    So if somebody has ENG 1003 but not ENG 1013 then I'd like my out to tell them that they one one but not the other. If they have both I'd like to tell them they have completed the segment.

    I'm kind of stumped on how to put that into coding though.
     
  7. SwoLy-D

    SwoLy-D Member

    Joined:
    Jul 20, 2001
    Messages:
    37,619
    Likes Received:
    1,460
    The way you "hard code" explicit values into your Boolean statements scares the programmer heart in me, man. :(

    Create FLAGs that are initiated as "false" from the get go, then check each instance and make the flag "true" after you go through the record if they have taken them, then at the end build a text string only if all are true. For the most part, the "all_true" question will be false all the time until all requirements are met. THEN use a case-select.

    Step back and write the plan out. Make an action and a decision tree. Write out what your code will do were all conditions true:
    Code:
    // Game hasn't started, so these are all false from the get-go:
    $vick_is_good = false;
    $vick_runs_well = false;
    $vick_is_not_injured = false; //same as "$vick_is_healthy = true;"
    $desean_acts_properly = false;
    $eagle_defense_plays_well = false;
    $eagles_win = false;
    
    
    /* here you loop through checks
    function loop_through_checks_if_any_of_the_above_are_true {
    	//check each record }
    */
    
    //I forget if this is still the syntax to check "trues", but you get the idea
    if ( $vick_runs_well && $vick_is_good && $vick_is_not_injured && $desean_acts_properly && $eagle_defense_plays_well) { 
    	$eagles_win = true;
    	echo "Eagles WIN!";}
    // else do nothing. ;)
    It's just an idea. :cool: Good luck, sir.
     
  8. Billy Bob

    Billy Bob Member

    Joined:
    Nov 1, 2009
    Messages:
    591
    Likes Received:
    21
    Holy code reading nightmare, Batman! You're writing the whole thing functionally (actually, are you even using functions)? May I suggest you learn OOP? Assuming the next person is a trainned programmer, he'll thank you for it.
     
  9. SwoLy-D

    SwoLy-D Member

    Joined:
    Jul 20, 2001
    Messages:
    37,619
    Likes Received:
    1,460
    What ever happened with this, 'Pun? Any updates? :confused:
     
  10. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    Still a work in progress. I'm looking at the example you gave me and the coding I have and trying to see where I need to go.

    Thanks! I'd rep you if I could. I'll keep you updated.
     
  11. SwoLy-D

    SwoLy-D Member

    Joined:
    Jul 20, 2001
    Messages:
    37,619
    Likes Received:
    1,460
    Ah, OK, coolio.

    I see you're messing with SQL, so I was wondering if this PHP thing was a done deal. Rep schmep, that doesn't matter to me... the goal here is that you finish this project.

    :cool: Keep up the good work, man.
     
  12. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    Yeah, they are two separate projects. I've got my books on PHP and SQL and have been reading them when I can but between work, classes, prepping for the GMAT, home and social life, etc. there's not a lot of room left in there for studying programming. :(
     
  13. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    OK, I am trying to highlight or color a row in a table based on a certain condition.

    Here is my code:

    Code:
    ?php
    //header('Content-Type: application/msword');
    error_reporting(0);
    $sql5 = "SELECT * FROM POSTED_GRADES where Subj_Code = '".$_POST["dutySearch"]."'";
    //echo $sql5;
    //die;
    //$sql5 = "SELECT * FROM POSTED_GRADES where Dept_Code LIKE '%".$_POST["dutySearch"]."%'";
    $srv5= odbc_connect("gradingdb", "gradeodbcuser", "*****************") or die("An error has occurred with this application.");
     
    $rs5=odbc_exec($srv5,$sql5);
     
     
    ?>
    !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    html>
    head>
     
    title>Term Grades/title>
    /head>
    body>
    table border='1' cellpadding='3'> tr>td colspan='6'>b>div align='center'>Posting Grades for ?php echo $_POST['dutySearch'] ?>/div>/b>/td>/tr>
    tr bgcolor='lightyellow'>td>Subject/td>td>CRN/td>td>Instructor/td>td>Student Name/td>/tr>
    ?php
     
    while ( $dkROWrecord = odbc_fetch_array($rs5))
            {
              $CRN_check=0;
            
             do {
            
                                                    
               echo "tr>";
       echo "td>".$dkROWrecord['Subj_Code']." ".$dkROWrecord['Course_Number']." ".$dkROWrecord['Section_Number']."/td> ";
             echo "td>".$dkROWrecord['Crn_Key']." /td> ";
      //  echo "td>".$dkROWrecord['Course_Title']." /td> ";
       echo "td>".$dkROWrecord['Instructor_First_Name']." ".$dkROWrecord['Instructor_Last_Name']." /td> ";
      
             echo "td>".$dkROWrecord['First_Name']." ".$dkROWrecord['Last_Name'];
    
             if($dkROWrecord = 'F'){
    echo "td style="background-color:#CC0000; color:#FFFFFF>".$dkROWrecord['grade']."/td>"
    }else{
    echo "td>".$dkROWrecord['grade']."/td>"
    }
    echo "/tr>";
    }
      
       while  ($CRN_check==$dkROWrecord['Crn_Key']);
    I keep getting the following errors (Line 56 is where else is):

    Parse error: parse error, unexpected T_ELSE, expecting ',' or ';' in D:\webroot\web\posting-grades\searchF3.php on line 56

    This one when simply implementing the code
    Parse error: parse error, unexpected }, expecting ',' or ';' in D:\webroot\web\posting-grades\searchF3.php on line 56

    Any suggestions?
     
    #13 Lil Pun, Dec 5, 2011
    Last edited: Dec 5, 2011
  14. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    EDIT: I think I figured it out.


    I actually got the code above working to an extent except that it highlights every row in the table instead of just the ones I made the condition on.:

    Code:
    while ( $dkROWrecord = odbc_fetch_array($rs5))
    		  {
    
    		 		 $CRN_check=0;
    				 
    				 do {						
    			  
    			  if($dkROWrecord['Pending'] = 'PN') {
    				echo "tr bgcolor='yellow'>";
    			echo "td>".$dkROWrecord['Subj_Code']." ".$dkROWrecord['Course_Number']." ".$dkROWrecord['Section_Number']."/td> ";
    			  echo "td>".$dkROWrecord['Crn_Key']." /td> ";
    		//  echo "td>".$dkROWrecord['Course_Title']." /td> ";
    		 echo "td>".$dkROWrecord['Instructor_First_Name']." ".$dkROWrecord['Instructor_Last_Name']." /td> ";
    			 
    			  echo "td>".$dkROWrecord['First_Name']." ".$dkROWrecord['Last_Name'];  
    				  
     }
    else {
    echo "tr>";
    			echo "td>".$dkROWrecord['Subj_Code']." ".$dkROWrecord['Course_Number']." ".$dkROWrecord['Section_Number']."/td> ";
    			  echo "td>".$dkROWrecord['Crn_Key']." /td> ";
    		//  echo "td>".$dkROWrecord['Course_Title']." /td> ";
    		 echo "td>".$dkROWrecord['Instructor_First_Name']." ".$dkROWrecord['Instructor_Last_Name']." /td> ";
    			 
    			  echo "td>".$dkROWrecord['First_Name']." ".$dkROWrecord['Last_Name'];
    
     
    #14 Lil Pun, Dec 6, 2011
    Last edited: Dec 6, 2011

Share This Page

  • About ClutchFans

    Since 1996, ClutchFans has been loud and proud covering the Houston Rockets, helping set an industry standard for team fan sites. The forums have been a home for Houston sports fans as well as basketball fanatics around the globe.

  • Support ClutchFans!

    If you find that ClutchFans is a valuable resource for you, please consider becoming a Supporting Member. Supporting Members can upload photos and attachments directly to their posts, customize their user title and more. Gold Supporters see zero ads!


    Upgrade Now