+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Little Chunk of PHP code

  1. #1
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Little Chunk of PHP code

    Can you guess what this does. it was hard to write so i hope its hard to guess

    PHP Code:
                  <?php
                  $array1 
    = array();
                  
    $query1 mysql_query("SELECT * FROM `point_option`") or die(mysql_error());
                    while (
    $row1 mysql_fetch_array($query1)){
                      echo 
    "<td>".$row1['name']."</td>";
                      
    $array1[] = $row1['name'];
                    }
                    
    ?>
                </tr>
                  <?php
                    $grade 
    $_GET['grade'];
                    
    $query mysql_query("SELECT * FROM `points` WHERE `grade` = '$grade'") or die(mysql_error());
                    while (
    $row mysql_fetch_array($query)){
                  
    ?>
                <tr>
                  <td><?php echo $row['name']; ?></td>
                  <td><?php echo $row['grade']; ?></td>
                  <?php
                  
    foreach($array1 as $fName => $fInfo){
                      echo 
    '<td>'.$row[$fInfo].'</td>';
                    }
                  
    ?>
                </tr>
                <?php
                
    }
                
    ?>

    btw: Alejandro is not allowed to answer
    Last edited by Chris S; 12-07-2006 at 09:30 PM.

    I would love to change the world, but they won't give me the source code

  2. #2
    bigguy's Avatar
    bigguy is offline Retired bigguy is an unknown quantity at this point
    Join Date
    Mar 2005
    Location
    Canada
    Posts
    5,426

    Re: Little Chunk of PHP code

    It looks like it gets a name and grade of a person and shows it on a page. Is that right. ???
    P.C. Tweakr - For all your computer and internet support
    P.C. Tweakr - For all your SMF help and support

  3. #3
    the_king_dollars's Avatar
    the_king_dollars is offline x10 Sophmore the_king_dollars is an unknown quantity at this point
    Join Date
    Nov 2006
    Posts
    153

    Re: Little Chunk of PHP code

    Does it bring the name of a person, his grade, and the number of points he achieved?

  4. #4
    Trixter is offline x10 Lieutenant Trixter is an unknown quantity at this point
    Join Date
    Oct 2006
    Posts
    384

    Re: Little Chunk of PHP code

    PHP Code:
    <?php
                  $array1 
    = array();
                  
    $query1 mysql_query("SELECT * FROM `point_option`") or die(mysql_error());
                    while (
    $row1 mysql_fetch_array($query1)){
                      echo 
    "<td>".$row1['name']."</td>";
                      
    $array1[] = $row1['name'];
                    }
                    
    ?>
                </tr>


    Copys All Names In point_option Table To $array1

    PHP Code:
    <?php
                    $grade 
    $_GET['grade'];
                    
    $query mysql_query("SELECT * FROM `points` WHERE `grade` = '$grade'") or die(mysql_error());
                    while (
    $row mysql_fetch_array($query)){
                  
    ?>


    Fetchs Certain Grades Defind By $grade Which looks to Be Pulled From A Form Field

    PHP Code:
     <tr>
                  <td><?php echo $row['name']; ?></td>
                  <td><?php echo $row['grade']; ?></td>
                  <?php
                  
    foreach($array1 as $fName => $fInfo){
                      echo 
    '<td>'.$row[$fInfo].'</td>';
                    }
                  
    ?>
                </tr>
                <?php
                
    }
                
    ?>


    Displays Names, Grades And List Number After The Query Has Run.
    Thats What I Think
    Last edited by Trixter; 12-08-2006 at 01:49 AM.
    Current:

    Latest:



  5. #5
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: Little Chunk of PHP code

    you are getting close. it does grab the people from a grade. but what does the array have to do with anything. doesn't look like people have figured that one out

    heres what it outputs.

    I did a little modifying to the output of the function that creates the array, but nothing else changed

    Last edited by Chris S; 12-08-2006 at 09:46 AM.

    I would love to change the world, but they won't give me the source code

  6. #6
    YamiKaitou's Avatar
    YamiKaitou is offline x10 Elder YamiKaitou is an unknown quantity at this point
    Join Date
    Oct 2006
    Posts
    636

    Re: Little Chunk of PHP code

    Not sure where $fName and $fInfo come from, but judging by your output, it gets their name, their grade, and whether they attended the meeting in that month.

  7. #7
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: Little Chunk of PHP code

    its really hard to see and the tables aren't that clear

    what it does it queries 1 table for field names, and then makes an array.

    then it queries another table for the information. it uses the array because the fields will change and i as the coder will not know what will be happening 2 years from now. So then using that array that was made, which contain the field names, it echos the field with the name from the array.

    it was hard to write because i had no idea how i was going to output the rows and get the different field names because they will change.

    I would love to change the world, but they won't give me the source code

  8. #8
    Brandon's Avatar
    Brandon is offline Former Senior Account Rep Brandon is on a distinguished road
    Join Date
    Jun 2006
    Location
    Tewksbury, MA
    Posts
    9,589

    Re: Little Chunk of PHP code

    Whats up with this

    btw: Alejandro is not allowed to answer
    DOnt be mean to admins.
    Thanks,
    Brandon Long

  9. #9
    amr1991's Avatar
    amr1991 is offline x10 Sophmore amr1991 is an unknown quantity at this point
    Join Date
    Jul 2006
    Posts
    198

    Re: Little Chunk of PHP code

    Looks like to me before you told is a reputation mod for some kind of forum system





  10. #10
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: Little Chunk of PHP code

    no he helped me make the code

    I would love to change the world, but they won't give me the source code

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Hybrid's HTML Lessons
    By Hybrid in forum Tutorials
    Replies: 18
    Last Post: 11-28-2009, 02:12 PM
  2. how can i convert Php pages and code into asp pages and code
    By n4tec in forum Scripts & 3rd Party Apps
    Replies: 11
    Last Post: 01-10-2009, 09:40 PM
  3. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  4. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  5. syntax highlighting for PHP code
    By dharmil in forum Graphics & Webdesign
    Replies: 1
    Last Post: 08-03-2006, 05:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers