Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 39

Thread: Changing Data In MySQL Through PHP

  1. #21
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Found the problem and editted the code I posted above. The edit is the part in red. That should fix it.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  2. #22
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry I should have mentioned I spotted that and fixed it earlier, this is the error

    Parse error: parse error, expecting `']'' in \showMembers.php on line 158
    I don't know if this helps but I can see a few yellow errors in dw when I look at it, it says </div> on line 150, </td> on line 151 and also </tr> on line 164... The dw error is MarkUp invalid because it's an overlapping or unclosed tag. But looked through it and they look fine to me could just be Dreamweaver being painful...

  3. #23
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Here it is, it is on this line, again editted the code I posted. Sorry about the miss.

    Code:
    <td><?=$q['Email'];?></td>
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  4. #24
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi there... Damn it I missed that!

    It doesn't like the last line the ?> closing tag...

  5. #25
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    ok, that's it. I think it is time for bed. Try adding the part in red to these lines:

    Code:
    if (empty($_GET['order'])) {
    $order = LastName;
    }
    else {
    $order = $_GET['order'];
    }
    Also editted the code that has been causing these errors. Sorry, but I'm getting offline to get ready for bed. Anyways, hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #26
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Ok, I editted the code once again according to your screenshot. This should do it, but if not, let me know.

    Code:
    <?php
    
    if ($_GET['cat'] == "") {
     $cat = "A"; //set this to your default category
    }
    
    else {
    $cat = $_GET['cat'];
    }
    
    /* connect to the mysql database and use a query to get the members info */
    
    include 'library/config.php';
    include 'library/opendb.php';
    
    //navigation
    include("nav.php");
    
    //approved
    $aCount = mysql_query("SELECT COUNT(*) FROM `tblmembers` WHERE `MemberApproved`='A'");
    
    //deleted
    $dCount = mysql_query("SELECT COUNT(*) FROM `tblmembers` WHERE `MemberApproved`='D'");
    
    //on hold
    $hCount = mysql_query("SELECT COUNT(*) FROM `tblmembers` WHERE `MemberApproved`='H'");
    
    //pending
    $pCount = mysql_query("SELECT COUNT(*) FROM `tblmembers` WHERE `MemberApproved`='P'");
    
    //not sure
    $nCount = mysql_query("SELECT COUNT(*) FROM `tblmembers` WHERE `MemberApproved`='N'");
    
    //rejected
    $rCount = mysql_query("SELECT COUNT(*) FROM `tblmembers` WHERE `MemberApproved`='R'");
    
    if ($cat == "a") {
    $field = "Approved";
    $theCount = $aCount;
    }
    
    elseif ($cat == "d") {
    $field = "Deleted";
    $theCount = $dCount;
    }
    
    elseif ($cat == "h") {
    $field = "On Hold";
    $theCount = $hCount;
    }
    
    elseif ($cat == "p") {
    $field = "Pending";
    $theCount = $pCount;
    }
    
    elseif ($cat == "n") {
    $field = "Not Sure";
    $theCount = $nCount;
    }
    
    elseif ($cat == "r") {
    $field = "Rejected";
    $theCount = $rCount;
    }
    
    echo 'There are '.$theCount.' members that are '.$field;
    
    /* if order is not set, or it is not in the allowed
     * list, then set it to a default value. Otherwise, 
     * set it to what was passed in. */
    
    if (empty($_GET['order'])) {
    $order = 'LastName';
    }
    else {
    $order = $_GET['order'];
    }
    
      if ($_REQUEST['act'] == "del") {
    
    $del = $_REQUEST['del'];
     
    mysql_query("UPDATE `tblmembers` SET `status`='D' WHERE `userID`='$del'");
    
    
    header('Location: '.$_SERVER["PHP_SELF"]);
      }
    
      elseif ($_REQUEST['act'] == "edit") {
    $id = $_REQUEST['id'];
    $status = $_REQUEST['status'];
    
    mysql_query("UPDATE `tblmembers` SET `status`='$status' WHERE `userID`='$id'");
    
    header('Location: '.$_SERVER["PHP_SELF"]);
      }
    
      else {
    
    
    
    /* construct and run our query */
    $query = "SELECT * FROM tblmembers WHERE `MemberApproved`='$cat' ORDER BY `$order`";
    
    $result = mysql_query ($query);
    
    /* make sure data was retrieved */
    $numrows = mysql_num_rows($result);
    if ($numrows == 0) {
        echo "No data to display!";
        exit;
    }
    
    
    echo '<script type="text/javascript">
    function showForm(id) {
    
    obj = document.getElementById(\'edit_\'+id);
    
     if (obj.style.display == "none") {
         obj.style.display = "";
     }
    
     else {
         obj.style.display = "none";
     }
    }
    </script>
    
    
    <table border="1">
     <tr>
      <td> &nbsp;</td>
      <td> &nbsp;</td>
      <td><a href="?order=FirstName">FirstName</a></td>
      <td><a href="?order=LastName">LastName</a></td>
      <td><a href="?order=PhoneNumber">PhoneNumber</a></td>
      <td><a href="?order=MobileNumber">MobileNumber</a></td>
      <td><a href="?order=Email">Email</a></td>
      <td><a href="?order=City">City</a></td>
      <td><a href="?order=State">State</a></td>
      <td><a href="?order=JoinDate">JoinDate</a></td>
      <td><a href="?order=MemberApproved">MemberApproved</a></td>
      <td><a href="?order=loginDateTime">loginDateTime</a></td>
     </tr>';
    
    /* Now display the data */
     while ($q = mysql_fetch_array($result)) {
    ?>
     <tr>
       <td><a href="#" onclick="showForm('<?php echo $q["id"];?>'); return false;">Edit</a>
    
    <div id="edit_<?php echo $q['id'];?>" style="display: none;">
    <!--status form-->
    
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
    <input type="hidden" name="act" value="edit">
    <input type="hidden" name="id" value="<?php echo $q['id'];?>">
    
    <select name="status">
    <option value="A">Approved</option>
    <!--enter options for status menu-->
    </select>
    
    </div>
       </td>
    
       <td><a href="?del=<?php echo $q['id'];?>&act=del">Delete User</a></td>
      <td><?=$q['FirstName'];?></td>
      <td><?=$q['LastName'];?></td>
      <td><?=$q['PhoneNumber'];?></td>
      <td><?=$q['MobileNumber'];?></td>
      <td><?=$q['Email'];?></td>
      <td><?=$q['City'];?></td>
      <td><?=$q['State'];?></td>
      <td><?php echo date('d-m-Y', strtotime($q["JoinDate"]));?></td>
      <td><?=$q['MemberApproved'];?></td>
      <td><?php echo date('d-m-Y', $q['loginDateTime']);?></td>
     </tr>
    <?php
     }
     
    echo '</table>';
    }
    ?>
    Hope this helps.
    Last edited by thetestingsite; 03-31-2007 at 01:47 AM.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #27
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Strange still just displays the 2 members...

  8. #28
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    I'm wondering if this has to do with the category (or member status) not being set in the script. Try my edit in my post above (the part in red at the very top). If that doesn't work, send me a screenshot of what is happening and I'll see what I can do.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #29
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well that has fixed that part great! It displays all, but the edit doesn't work or delete...

  10. #30
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    ok, added another part in red in the above posted code. Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •