Jump to content

slotegraafd

Members
  • Posts

    35
  • Joined

  • Last visited

  • Days Won

    1

slotegraafd last won the day on June 4 2020

slotegraafd had the most liked content!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

slotegraafd's Achievements

Member

Member (2/5)

1

Reputation

  1. ope sorry if ($keys[$recordCount] == "logo" && $totalRows[$column] != "") { echo '<td class="py-2"><img src="' . $totalRows[$column] . '" alt="Client Logo" class="logo-thumbnail" /></td>'; //Check whether or not the client is active or inactive } else if ($keys[$recordCount] == "enabled") { $userId = $data[$record]['id']; $enabled = $data[$record]['status']; echo ' <td class="py-2">'. '<form method="POST" action="salesperson.php"> <div> <input type="radio" name="active[' . $userId . ']" value="Active" '; if($enabled == "a") { echo 'checked'; }; echo '/> <label for="' . $userId . '-Active">Active</label> </div> <div> <input type="radio" name="active[' . $userId . ']" value="Inactive" '; if($enabled == "d") { echo 'checked'; }; echo '/> <label for="' . $userId . '-Inactive">Inactive</label> </div> <input type="submit" name="submitType" value="Update" /> </form> Current Status: '. $totalRows[$column] . "</td>"; (its created as a function)
  2. So I am trying to create a table where users can be disabled and enabled with the press of a radio button. So for the most part it works but for some reason it only allows me to disable a user it wont let me enable them and I can't seem to figure out why. I've checked that all the names were correct with the database and I have also tried both single ' quotes and double " quotes on the prepared statements to see if that makes a difference... it did not These are the functions to disable and enable users function inactive($userId){ $conn = db_connect(); $disable_user = pg_prepare($conn, 'disable', "UPDATE users SET Enabled = false, Status = 'd' WHERE Id = $userId"); $result = pg_execute($conn, 'disable', array()); } //Create a function to activate a salesperson function active($userId){ $conn = db_connect(); $enable_user = pg_prepare($conn, 'enable', "UPDATE users SET Enabled = true, Status = 'a' WHERE Id = $userId"); $result = pg_execute($conn, 'enable', array()); } $id = (array_keys($_POST['active'])[0]); $status = $_POST['active'][$id]; if($status == "t"){ active($id); } else{ inactive($id); } And this is where it gets put into action ^^ In the database I have a boolean for enabled which is either true or false and then I have a varchar for status which is either 'd' or 'a' Any help would be greatly appreciated Thanks in advance
  3. Okay well can you show me where exactly you put that stuff in my code so I can see if maybe i put it in the wrong spot
  4. Everything else is right though? Cuz it still doesnt work
  5. Is this how you did it. Idk what im missing $lastRecord = min($firstRecord + ROWS_PER_PAGE, $rows); for($record = $firstRecord; $record < $lastRecord; $record++){ $row = $data[$firstRecord + ROWS_PER_PAGE]; echo '<tr>'; for($recordCount = 0; $recordCount < count($keys); $recordCount++){ $column = $keys[$recordCount]; echo '<td class="py-2">' . $row[$column] . '</td>'; } echo '</tr>'; }
  6. Okay so that didnt in fact get rid of the errors I was getting but now it doesnt show any of the data
  7. display_table( array( "id" => "Id", "emailaddress" => "Email", "firstname" => "First Name", "lastname" => "Last Name", "salesperson" => "Salesperson", "phonenumber" => "Phone Number", "extension" => "Extension", "type" => "Type" ), client_select_all(), client_count(), 1 ); I forgot to add the last part of this, I have those two as other functions to for the data and rows and such
  8. What do you mean? Cuz it does actually show the data in the table still
  9. Hi, WHAT: So I cannot for the life of me figure out why I'm getting this error. I'm trying to create a function that will display the user information from the database in a table but I have like a ton of these errors on the page and I don't know whats wrong. STEPS TO RESOLVE: So I've gone over my code a bunch of types to make sure that all the variables and what not were spelled correctly and as far as I can tell they are. I've also googled this issue to see if I can find a solution but none of them are very helpful. I honestly don't know whats wrong so kinda hard to find ways to resolve an issue, I don't even really know what this error means. THE CODE: This is where I put the function into action <?php display_table( array( "id" => "Id", "emailaddress" => "Email", "firstname" => "First Name", "lastname" => "Last Name", "salesperson" => "Salesperson", "phonenumber" => "Phone Number", "extension" => "Extension", "type" => "Type" ) ); ?> //This is the function <?php function display_table($fields, $data, $rows, $page){ if(isset($_GET['page'])){ $page = $_GET['page']; } else { $page = 1; } $firstRecord = ($page - 1) * ROWS_PER_PAGE; $pageNumbers = ceil($rows / ROWS_PER_PAGE); echo '<div class="table-responsive w-75 mx-auto py-3"> <table class="table table-dark table-bordered table-sm"> <thead> <tr>'; foreach($fields as $key){ echo '<th class="py-2">' . $key . '</th>'; } echo '</tr> </thead> </tbody>'; $keys = array_keys($fields); for($record = $firstRecord; $record < $firstRecord + ROWS_PER_PAGE; $record++){ $row = $data[$record]; echo '<tr>'; for($recordCount = 0; $recordCount < count($keys); $recordCount++){ $column = $keys[$recordCount]; echo '<td class="py-2">' . $row[$column] . '</td>'; } echo '</tr>'; } echo '</tbody> </table'; for($pages = 1; $pages <= $pageNumbers; $pages++){ echo '<a class="btn btn-dark mx-1" href=?page=' . $pages . '</a>'; } } ?> Any help/advice would be really appreciated
  10. // Form Fields Arrays: Field Title, Field Name, Field Type $display_form = array( array( "type" => "text", "name" => "first_name", "value" => "", "label" => "First Name" ), array( "type" => "text", "name" => "last_name", "value" => "", "label" => "Last Name" ), array( "type" => "email", "name" => "email", "value" => "", "label" => "Email" ), array( "type" => "number", "name" => "extension", "value" => "", "label" => "Extension" ), ); foreach ($display_form as $key => $value) { echo "<label for='{$value[1]}'>{$value[3]}</label>\n<input id='{$value[1]}' name='{$value[1]} type=\"{$value[0]}' value='{$value[2]}' ><br><br>\n\n"; } ?> <input type="submit" name="submit" value="Submit" class="button"> </fieldset> </form>
  11. Oh so I’m using the array that I have in my code there. (I’m really bad with arrays if you couldn’t tell) I thought that each one in the array corresponded to a number no matter what type of arrays
  12. @benanamen Ah I see, Notice: Undefined offset: 2 in C:\XAMPP\htdocs\Webd3201\salesperson.php on line 83 though do you know what this error means?
  13. Hey, So I'm doing a school assignment and my professor wants us to use an array to display forms and I have no idea how to do that. He wants us to create an array of arrays like this: display_form( array( "type" => "text", "name" => "first_name", "value" => "", "label" => "First Name" ), array( "type" => "text", "name" => "last_name", "value" => "", "label" => "Last Name" ), array( "type" => "email", "name" => "email", "value" => "", "label" => "Email" ), array( "type" => "number", "name" => "extension", "value" => "", "label" => "Extension" ) ); But I dont understand how you use that array to actually display the form. Does anyone know how?
×
×
  • 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.