Jump to content

jay7981

Members
  • Posts

    175
  • Joined

  • Last visited

About jay7981

  • Birthday 01/25/1979

Contact Methods

  • MSN
    jay@angeldyne.com
  • Yahoo
    fuk.this_shit

Profile Information

  • Gender
    Male
  • Location
    Tampa, FL
  • Age
    34

jay7981's Achievements

Member

Member (2/5)

1

Reputation

  1. Thank you so much for breaking this down for me and thanks to you i now understan a bit better and that is all i was asking for. You have helped me tremendosly and i have learned alot from this.
  2. ok so i tried that query inplace of mine and am getting a blank page do i need to stop using the function with it? i'm sorry as i do not know much about this type of logic as i am still learning. and i think that is where me and Jess got off on the wrong foot, i did not mean to come across as ungreatful because i am greatful that sites like this exsist to help people like me. what i did was simply changed my query to yours, was there something else i missed or did not do?
  3. anyways your "solution" although broken (== instead of =) i had already corrected and am getting a blank page.
  4. yea so that didnt work, getting syntax errors .... anyone else got a solution that is actually going to work ?
  5. Table has Name Class hide John Option A 0 bob Option B 0 chris Option C 0 tom None 0 sam Option A 1 Output should be Option A John Option B bob Option C chris None tom sam Currently Getting Option A John sam Option B bob Option C chris None tom
  6. Ok so how do i fix it to do what i am wanting? obviously i dont know
  7. $class1 is being used at the end of the while because of the function being ran on the loop gathering names based on the class, i dont see how this would impair me forcing a class on users that have a hide of 1. **Desired OutPut** in the db there are 4 classes (Option A, Option B, Option C, None) and 2 Hide (0 , 1) If john has Option A and Hide of 1 i am wanting him listed with the rest that have None in thier class but if john has Option A and Hide of 0 he should be with the rest of Option A's ** End Desired OutPut** **What I'm Getting** The script works fine minus me trying to force a class on someone with hide set to 1 **End What I'm Getting**
  8. i tried this as well and got the same results if ($row['hide'] == "1") { $class1 = "None"; } //end $class1 = $row['class_1']; $users = array(); to if ($row['hide'] == "1") { $class1 = "None"; }else{ //end $class1 = $row['class_1']; } $users = array();
  9. Hey guys/gals, I have a table, and i am listing all names with thier associated class the problem i am having is i need to force a users class to "None" if thier hide field is "1" this is what i have done and its not working ... i have commented the code that is not working, as for the rest it is working great. <?php include("./sql-conn.php"); function outputClassList($class1, $users) { if (!$class1) { return false; } $userCount = count($users); $output = "<br>\n<b>{$class1}</b> ({$userCount})"; $output .= "<br>\n"; $output .= implode("<br>\n", $users); $output .= "<br>\n"; return $output; } $db = mysql_connect($hostname, $username, $password) or die('Failed to connect to database: ' . mysql_error()); mysql_select_db($database); $query = "SELECT class_1, name, hide FROM class ORDER BY class_1, name ASC" or die('Failed to Query: ' . mysql_error()); $result = mysql_query($query) or die('Failed Getting Results: ' . mysql_error()); $class1 = false; while ($row = mysql_fetch_assoc($result)) { if ($class1 != $row["class_1"]) { echo outputClassList($class1, $users); //this isn't working if ($row['hide'] == "1") { $class1 = "None"; } //end $class1 = $row['class_1']; $users = array(); } $users[] = ucfirst($row['name']); } //print_r ($users); echo outputClassList($class1, $users); mysql_free_result($result); mysql_close($db); ?>
  10. Dude You Rock!! Thanks so much that has been driving me crazy for hours ... Worked like a charm!
  11. your assumtion is correct, you can have any variation of the 3 in the same field, as for the implode i am joining the checkbox data together and then setting $actdata to that data as a comma seperated list and that is what is stored in the table. this is going to be an edit page, so i will need to have all 3 boxes statically in place and i will have a query pull the data from table and check the boxes accordingly so that the user could either add a selection or remove then re submit the form
  12. Hey all i am trying to select checkboxes using MySQL data that is in an array i have 3 checkboxes Open Close Break in the database i have a field "action" in the field is the data "Open,Close,Break" i know i can use <?= ($action=='Open')? 'checked="checked"' : '' ?> but i need to have all boxes that match the data in the field selected ... how do i go about doing this ? here is the form code for the specific field i am working with. $action= $res['action']; $actdata= implode(",", $action); <tr> <td>Action</td> <td><input type="checkbox" name="action[]" value="Open" /> Open <input type="checkbox" name="action[]" value="Close" /> Close <input type="checkbox" name="action[]" value="Break" /> Break</td> </tr>
  13. I Guess you were right i just needed to look a bit harder ... so after a shot of whiskey and a smoke ... This works <?php include_once("./pages/membership/config.php"); $count=mysql_query("SELECT COUNT(*) FROM botb_members"); $r = mysql_fetch_row($count); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 15; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; ?> <?php $result=mysql_query("SELECT * FROM botb_members ORDER BY LName ASC LIMIT $offset, $rowsperpage"); ?> <table align="center" width="100%" border="0" cellspacing="2" cellpadding="2"> <td><p>There are <?php echo $numrows ; ?> Members</p></td> </tr> <tr> <td><?php if ($loggedInUser->checkPermission(array(5))) { ?> <button onclick="window.location.href='member-db.php?add'">Add Member</button> <?php } ?></td> </tr> </table> <br/> <table width="75%" align="center" border=1 style="white-space:nowrap"> <tr bgcolor='#CCCCCC'> <td><div align="center">Action</div></td> <td><div align="center">MemberID</div></td> <td><div align="center">Name</div></td> <td><div align="center">Department</div></td> <td><div align="center">Status</div></td> </tr> <?php while($res=mysql_fetch_array($result)){ $status = "Active"; if ($res['Revoked_Removed']=="x"){ $status = "Revoked"; } if ($res['Deceased']=="x"){ $status = "Deceased"; } if ($res['Inactive']=="x"){ $status = "Inactive"; } ?> <tr> <td><a href="member-db.php?viewid&ID=<?php echo $res['ID']; ?>">View</a> <?php if ($loggedInUser->checkPermission(array(5))) { ?> | <a href="member-db.php?edit&ID=<?php echo $res['ID']; ?>">Edit</a> | <a href="member-db.php?delete&ID=<?php echo $res['ID']; ?>">Delete</a> <?php } ?> </td> <td><?php echo $res['mID']; ?></td> <td><?php echo $res['FName']; ?> <?php echo $res['LName']; ?> <?php echo $res['Suffix']; ?></td> <td><?php echo $res['Department']; ?></td> <td><?php echo $status; ?></td> <?php } $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?view&currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?view&currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?view&currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?view&currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?view&currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?> </table>
  14. please dont take this the wrong way as i am sick and dopped up on all sorts of meds at the moment, i cant see any error from my point of view as i have already stated i dont know anything about pagination, i cant learn from a mistake if i cannot identify the mistake and all i really want to do is learn, so if you would kindly point out the mistake and help me through this without being cyrptic it would be much appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.