Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About PythonHelp

  • Rank
  1. Thank you, When I select three records with user IDs 6, 7 , 8, I get this output and assigns user_id (8) to all the selected records. <td><input type="checkbox" name="checkbox[<?php echo $row['user_id']; ?>]"></td> I am really stuck as I have no worked example to work from.
  2. OK, so I have progressed a little, I am now using Prepared statements and now I can insert the number of rows based on the selections, and it will insert the class ID, however, only the last student's userID gets inserted in each row even when it is not selected. <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); ?> <?php mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); ?> <?php $servername = "xxxxxt"; $username = "webxxxx"; $password = "xxxx!"; $dbname = "xxx"; // Create con
  3. My first attempt is in post number 1 My second attempt is is post number 7 after trying to act upon your suggestions with my little PHP coding experience. My third attempt was making the checkbox field an array, with the array index being the user_id value I am not a coder, but I can make some sense from worked examples/tutorials. So now my code is at this stage and really need some guidance: $class_id = $_POST['class_id']; // This value is from a dropdown $checkbox = $_POST['checkbox']; // This is a checkbox next to each record $user_id = $_POST['user_id']; // this
  4. Step 1 completed: Thanks I now need guidance with: - if any of the checkboxes are checked, you will get an array with the indexes being the user_ids (i would use array_keys() to get all of them as an array to loop over). you would then use a prepared query, prepared once before the start of any looping, to insert each row of data.
  5. Hi, Thank you. I am trying to follow what you advised, I am not a programmer and new to PHP, I did some further research and tried to apply to what you said: HTML: <?php $outcome = ''; $count=1; $sel_query="SELECT * FROM User_Accounts_"; $stmt = $conn->prepare($sel_query); $stmt->execute(); $result = $stmt->get_result(); // get the mysqli result if($result->num_rows === 0) exit('No Users'); $i = 0; while($row = $result->fetch_assoc()) { ?> <td><input name="checkbox[]" type="checkbox" value="Yes" value=<?
  6. <td><input name="checkbox" type="checkbox" value="Yes"></td> <td><input name="user_id" type="text" size="2" value="<?php echo $row["user_id"]; ?>" /></td> <td><?php echo $row["username"]; ?></td> <td><?php echo $row["firstname"]; ?></td> <td><?php echo $row["lastname"]; ?></td> <td><?php echo $row["School"]; ?></td> <td><?php echo $row["Year"]; ?></td> <td><?php echo $row["Form"]; ?></td>
  7. OK great, I found that at the EOF there was a curly bracket missing. So now, the append is working but it only adds the last row in the table, even if the others are selected and the last row isn't.
  8. <?php $servername = "xxx"; $username = "xxxx"; $password = "xxxx"; $dbname = "web216-admin-6d5"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } $class_id = $_POST['class_id']; // This value is from a dropdown $checkbox = $_POST['checkbox']; // This is a checkbox next to each record $user_id = $_POST['user_id']; // this is a hidden value output from the database (in a textbox) if(isset($_POST['submit'])) { for($i=0;$i<count($checkbox);$i++){ $query="
  9. Thank you! (A silly mistake 🙉) Yes, on login, the user level is checked and the user is re-directed to the relevant page! so non admin will not see the admin options.
  10. Hi, I am trying to get this script to execute as an administrator of an online system. If a user has forgotten their password, I enter their username and enter a new password which they can update later. I am not sure why this is not updating the password for the username entered? <?php // Initialize the session session_start(); // Check if the user is logged in, if not then redirect to login page if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){ header("location: login.php"); exit; } // Include config file require_once "config
  11. I didn't seem to locate the missing curly brace
  12. Hi ! I am trying to translate my mysqli count query that works perfectly into prepared statements. Unfortunately, after playing around and using my knowledge of PS, I have come up with this script which fails to execute and returns a http 500 error. I may have missed something very silly, I require some guidance on fixing the error. <?php $conn = mysqli_connect("xxxx", "xxxx", "xxxx", "xxx"); $sel_query = "SELECT S1, B1 COUNT(IF(S1 = ?, 1, NULL)) 'Accepted', COUNT(IF(S1 = ?, 1, NULL)) 'Rejected', COUNT(IF(S1 = ?, 1, NULL)) 'Under_Review'
  13. I have but not sure which section can help me. Guidance needed please.
  14. Thank you so much, with your support, I am learning as well as becoming a step closer to the end result. So, after looking at the PHP manual, I have altered the script , but now it is producing the error ""Notice: Undefined index for the following lines: <td><?php echo $row['Form_Group']; ?></td> <td><?php echo $row['Present']; ?></td> <td><?php echo $row['Absent']; ?></td> Here is the entire code <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); ?&
  15. I believe it is a mysql error , after removing the ' ' around the table name, I am getting: Fatal error: Call to undefined method mysqli_result::fetch_rows() in \\143FF240DC.STORAGE-1B.HOSTING.STACKCP.NET\SITES\1b\1\143ff240dc\public_html\Progress_Tracker\Pages\reports_attendance.php on line 65 After removing the single quotes, I am getting: Fatal error: Call to undefined method mysqli_result::fetch_rows() in \\143FF240DC.STORAGE-1B.HOSTING.STACKCP.NET\SITES\1b\1\143ff240dc\public_html\Progress_Tracker\Pages\reports_attendance.php on line 65
  • 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.