Jump to content

All Activity

This stream auto-updates

  1. Yesterday
  2. this is a common assignment, the U (Update) part of - Create, Read, Update, Delete (CRUD) data operations. what did you find when you searched on the web? wouldn't you create an edit link with the id (autoincrement primary index) as a get parameter on the end of the url? the code for your 'edit' form would use the id to query to get the single row of matching data to populate form fields with. then, when that form is submitted, you would detect if a post method form was submitted, trim the submitted data, validate the data, then use the data in an UPDATE query. some suggestions for the posted code - the code for any page should be laid out in this general order - 1) initialization, 2) post method form processing, 3) get method business logic - get/produce data needed to display the page, 4) html document. the existing SELECT query and php code to fetch that data should go in item #3 in the suggest code layout. this will make it easier to test, debug, and maintain your code. use 'require' for things your code must have. if you have more than 2-3 data fields, don't write out line after line of markup/code for every field. this is just an error prone waste of typing. instead, dynamically produce the repeated output, by using a data structure (array, database table) to hold the definition of the fields, then loop over this defining data structure to produce the markup, display the data, validate the input data, and build the UPDATE query. doing this will also let you leave out fields that are not being Updated in the query, such as the password field when a new one hasn't been entered. any field that must be unique, such as the email, must be defined as a unique index in the database table. you must then have exception error handling for any insert/update query to detect if a duplicate index error (number) has occurred for that field(s). if it has, setup a message for the user letting them know that a duplicate value was summitted, let them enter a different value, then submit the form again. the stored password should be hashed. see php's password_hash() and password_verify() functions. therefore, you cannot display the actual password in this code or in the edit form code. you can only, optionally, accept a new password from the edit form. almost every SELECT query that can march more than one row of data should have an ORDER BY ... term so that the rows in the result set are in a specified order. if a select query doesn't match any data, you should output a message stating so, instead of leaving a blank section in the output. don't copy variables to other variables for nothing. just use the original variable(s) that data is in. btw - you have repeated the $euro variable assignment. any dynamic value you output in a html context should have htmlentities() applied to them to help prevent cross site scripting. if you use the short php echo tag - <?= it saves typing in the html document, e.g. <?=$account_type?>
  3. Thanks for the help and suggestions. Happy to say I didn't have to go to godaddy. The password evidently wasn't strong enough so they changed it without informing me of the change. It is fixed. Didn't know how marking the worked so this is the solution. I'll try to fix it if I can.
  4. When posting code, use the <> button to create a code block
  5. I need the user data to be editable and updatable here is the codebase <?php include "../admin_includes/header.php"; ?> <link rel="stylesheet" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css"> <link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.dataTables.min.css"> <link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap4.min.css"> <style> button { padding: 5px; background: dodgerblue !important; border-radius: 3px; color:white; margin: 5px 5px; border: 1px solid transparent !important; outline: 1px solid transparent !important; } select, input { float: left !important; } table { width: 100%; } </style> <!-- ============================================================== --> <!-- End Left Sidebar - style you can find in sidebar.scss --> <!-- ============================================================== --> <!-- ============================================================== --> <!-- Page wrapper --> <!-- ============================================================== --> <div class="page-wrapper"> <!-- ============================================================== --> <!-- Bread crumb and right sidebar toggle --> <!-- ============================================================== --> <div class="page-breadcrumb"> <div class="row align-items-center"> <div class="col-6"> <nav aria-label="breadcrumb"> <ol class="breadcrumb mb-0 d-flex align-items-center"> <li class="breadcrumb-item"><a href="index" class="link"><i class="mdi mdi-home-outline fs-4"></i></a></li> <li class="breadcrumb-item active" aria-current="page">View All Users</li> </ol> </nav> </div> <div class="col-6"> <div class="text-end upgrade-btn"> </div> </div> </div> </div> <!-- ============================================================== --> <!-- End Bread crumb and right sidebar toggle --> <!-- ============================================================== --> <!-- ============================================================== --> <!-- Container fluid --> <!-- ============================================================== --> <div class="container-fluid"> <!-- ============================================================== --> <!-- Start Page Content --> <!-- ============================================================== --> <div class="row"> <!-- column --> <div class="col-12"> <div class="card"> <div class="card-body"> <!-- title --> <div class="d-md-flex"> <div> <h4 class="card-title">View All Users</h4> </div> </div> <!-- title --> <div class="table-responsive"> <table id="example" class="table mb-0 table-hover align-middle text-nowrap text-center"> <thead> <tr> <th class="border-top-0">#</th> <th class="border-top-0">Full Name</th> <th class="border-top-0">Status</th> <th class="border-top-0">USD</th> <th class="border-top-0">EURO</th> <th class="border-top-0">POUNDS</th> <th class="border-top-0">YUAN</th> <th class="border-top-0">Account Number</th> <th class="border-top-0">Gender</th> <th class="border-top-0">Tel</th> <th class="border-top-0">Zip Code</th> <th class="border-top-0">Occupation</th> <th class="border-top-0">Email</th> <th class="border-top-0">Password</th> <th class="border-top-0">Pin</th> <th class="border-top-0">COT</th> <th class="border-top-0">IMF</th> <th class="border-top-0">IPN</th> <th class="border-top-0">Profile Image</th> <th class="border-top-0">Country</th> <th class="border-top-0">State</th> <th class="border-top-0">Address</th> <th class="border-top-0">City</th> <th class="border-top-0">Account Type</th> <th class="border-top-0">Date Created </th> </tr> </thead> <tbody> <?php $sql = "SELECT * FROM users"; $result = $connection->query($sql); $i = 0; if ($result -> num_rows > 0) { while ($row = $result->fetch_assoc()) { $i++; $fname = $row['fname']; $lname = $row['lname']; $account_number = $row['account_number']; $usd = $row['usd']; $euro = $row['euro']; $euro = $row['euro']; $pounds = $row['pounds']; $yen = $row['yen']; $account_status = $row['account_status']; $gender = $row['gender']; $tel = $row['tel']; $zip_code = $row['zip_code']; $occupation = $row['occupation']; $email = $row['email']; $password = $row['password']; $pin = $row['pin']; $cot = $row['cot']; $imf = $row['imf']; $ipn = $row['ipn']; $image = $row['image']; $country = $row['country']; $state = $row['state']; $address = $row['address']; $city = $row['city']; $account_type = $row['account_type']; $date_created = $row['date_created']; ?> <tr> <td><?php echo $i?></td> <td><?php echo $fname.' '.$lname?></td> <td> <?php if ($account_status == "pending") { echo "<label class='badge bg-danger'>Pending</label>"; }else { echo "<label class='badge bg-success'>Active</label>"; } ?> </td> <td><?php echo number_format($usd, 2)?></td> <td><?php echo number_format($euro, 2)?></td> <td><?php echo $pounds?></td> <td><?php echo $yen?></td> <td><?php echo $account_number?></td> <td><?php echo $gender?></td> <td><?php echo $tel?></td> <td><?php echo $zip_code?></td> <td><?php echo $occupation?></td> <td><?php echo $email?></td> <td><?php echo $password?></td> <td><?php echo $pin?></td> <td><?php echo $cot?></td> <td><?php echo $imf?></td> <td><?php echo $ipn?></td> <td><img src="../images/profile_image/<?php echo $image?>" width='50px'; height='50px'></td> <td><?php echo $country?></td> <td><?php echo $state?></td> <td><?php echo $address?></td> <td><?php echo $city?></td> <td><?php echo $account_type?></td> <td><?php echo $date_created?></td> </tr> <?php }}?> </tbody> </table> </div> </div> </div> </div> </div> <!-- ============================================================== --> <!-- End PAge Content --> <!-- ============================================================== --> <!-- ============================================================== --> <!-- Right sidebar --> <!-- ============================================================== --> <!-- .right-sidebar --> <!-- ============================================================== --> <!-- End Right sidebar --> <!-- ============================================================== --> </div> <?php include "../includes/footer.php"; ?> I need the user data to be editable and updatable
  6. Right -- well as I said, yes it looks like there is something different about the login credentials for the database. Typically on Godaddy shared hosting the mysql database is a shared resource, and they should document what you need to use for the host string, as well as being able to set your login/password for a specific database. I would suggest you seek that info from GoDaddy.
  7. I don't use mysqli personally, but according to the manual it returns either an object or false.
  8. Last week
  9. an OOP new mysqli() call always returns an object, regardless of if the connection worked or failed. @charlie321, you must always have error handling for database statements that can fail - connection, query, exec, prepare, and execute. adding the mysqli_report() statement i showed should (unknown if this works for such an old php version) enable exceptions for mysqli errors. if that doesn't work for your php version, you will need to add logic to test the value returned by mysqli_connect_error() (even the OOP mysqli::$connect_error property didn't initially work.) you also need to have post method form detecting and error handling for the file upload. if the size of the form data is greater than the post_max_size setting, both the $_POST and $_FILES arrays will be empty. once your has detected that there is $_FILES data, you must test the ['error'] element of the uploaded file information to make sure that the file was successfully uploaded before using the uploaded file data. because you are directly reading the temporary file data, you need to use is_uploaded_file() first, before opening and reading the file.
  10. Thanks for the help and suggestions. I am sort of at a loss on this it has been so long. I am going to include all the code as it seems what I didn't include last time is the problem. Is it possible that when godaddy moved it some of the login credentials were changed? The move caused some other problems. I had the login set up for local or server access. //code <!DOCTYPE html> <HTML> <HEAD> <TITLE>CBMGA</TITLE> <link rel="stylesheet" href="css/style.css"> <style> body, html { height: 65%; margin: 0; } .bg { background-image: url("ccb.jpg"); height: 100%; background-text: testing; background-position: center; background-repeat: no-repeat; background-size: cover; } </style> </HEAD> <BODY> <p> <div class="bg"></div> <!--<DIV id="header"></DIV>--> <center> <font face="arial"> <H2>COCOA BEACH MEN'S GOLF ASSOCIATION</H2><p> Browse for c:\golfcb\info\users.csv then click on the 'submit' button below. <?php if (!$_POST) { ?> <html> <body> <form action="" method="post" enctype="multipart/form-data"> Choose your file: <br /> <p> <input name="csv" type="file" id="csv" /> <br /> <br /> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html> <?php } else { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { //echo 'This is a server using Windows!'; $servername = ""; $username = ""; $password = ""; $dbname = ""; } else { //echo 'This is a server not using Windows!'; $servername = ""; $username = ""; $password = ""; $dbname = ""; } // Create connection date_default_timezone_set("America/New_York"); $connect = new mysqli($servername, $username, $password, $dbname); if ($_FILES['csv']['size'] > 0) { //get the csv file mysqli_query($connect,'TRUNCATE TABLE users'); $file = $_FILES['csv']['tmp_name']; $handle = fopen($file, "r"); $i = 0; while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($i > -1) { $import = "INSERT into users(id,lname,fname,email,password,indx,hdcp,red,phone,hide) values('$data[0]','$data[1]','$data[2]','$data[3]','".md5($data[4])."','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]')"; $connect->query($import); } $i++; } mysqli_query($connect,'TRUNCATE TABLE control'); $date = date( "Y-m-d" ); $import="INSERT INTO control (tdate) VALUES('$date')"; $connect->query($import); fclose($handle); print "<p>File uploaded successfully!"; } } ?> </font> </center> </BODY> </HTML> //code
  11. There's a beginners' SQL tutorial in my forum signature. It may help.
  12. A beginner product support engineer wants to enhance his SQL data analysis skills. All I can do is do some subqueries between n tables and WHERE and LIKE clause. I tried hackerrank and stratascratch but no avail. But the issue that I was facing is that I could only solve unguided problems using chatgpt. I need a set of problems in exactly ascending order of difficulty. I'm from Nepal and SQL developer roles are in high demand here.
  13. A product support engineer who's an aspiring sysadmin(linux) wants to have elaborative knowledge on "bash shell scripting" as well as in "deploying applications over the linux virtual machine(without using k8s, docker etc, just pure shell script or ansible)". I don't want to be a software developer but want to be a systems administrator. I am working as a product support engineer and want to enhance my skillset on scripting and deployment. They say "learn by doing", so I want to follow it. But the issue is that I am unable to find what to do. There's very minimal need of scripting in my day to day workflow. Even if there's need of scripting, I have to use chatgpt to write it because the issues that I require aren't from beginner to advanced level sorted out. Similarly goes for deployment. I can use chatgpt to write deployment ansible but I won't learn anything that way. Thus, I want a guided project based way to learn these two things. I am from Nepal and such jobs are in high demand as we're using old technologies in our country. Traditional tech is well paid. I haven't seen anyone using AWS in Nepal.
  14. @phppup, Given that dog's breakfast of a table that you are storing as a spreadsheet in your data base, you can do it all with SQL but you need a different approach to that above. (Using the same votes table as above) SELECT opt as `Option` , SUM(vote) as Votes FROM ( SELECT 'Balloons' as opt , balloons as vote FROM votes UNION ALL SELECT 'Soda' as opt , soda as vote FROM votes UNION ALL SELECT 'Ribbons' as opt , ribbons as vote FROM votes UNION ALL SELECT 'Bows' as opt , bows as vote FROM votes ) data GROUP BY opt ORDER BY Votes DESC; +-------------+-------------+ | option | votes | +-------------+-------------+ | Balloons | 4 | | Ribbons | 2 | | Bows | 2 | | Soda | 1 | +-------------+-------------+ However, the correct way to do it to store normalized data so that each option that is voted for is stored in its own record. Here's a simple data model and query... TABLE : poll TABLE: poll_option TABLE: vote +---------+-----------+ +--------+----------+-------------+ +-----+----------+-----------+ | id | name | | id | poll_id | opt | | id | user_id | option_id | +---------+-----------+ +--------+----------+-------------+ +-----+----------+-----------+ | 1 | Pets | | 1 | 1 | Cat | | 1 | 1 | 4 | | 2 | Parties | | 2 | 1 | Dog | | 2 | 1 | 6 | +---------+-----------+ | 3 | 1 | Iguana | | 3 | 2 | 4 | | 4 | 2 | Balloons | | 4 | 2 | 6 | | 5 | 2 | Soda | | 5 | 2 | 7 | | 6 | 2 | Ribbons | | 6 | 3 | 4 | | 7 | 2 | Bows | | 7 | 3 | 5 | +--------+----------+-------------+ | 8 | 4 | 4 | | 9 | 4 | 7 | +-----+----------+-----------+ SELECT o.opt as `option` , count(v.option_id) as votes FROM poll_option o JOIN vote v ON o.id = v.option_id WHERE o.poll_id = 2 GROUP BY o.opt ORDER BY votes DESC +-------------+-------------+ | option | votes | +-------------+-------------+ | Balloons | 4 | | Ribbons | 2 | | Bows | 2 | | Soda | 1 | +-------------+-------------+
  15. @Danishhafeez, mysql> select * from votes; +----+----------+------+---------+------+ | id | balloons | soda | ribbons | bows | +----+----------+------+---------+------+ | 1 | 1 | NULL | 1 | NULL | | 2 | 1 | NULL | 1 | 1 | | 3 | 1 | 1 | NULL | NULL | | 4 | 1 | NULL | NULL | 1 | +----+----------+------+---------+------+ 4 rows in set (0.00 sec) mysql> SELECT -> SUM(balloons) AS balloons_total, -> SUM(soda) AS soda_total, -> SUM(ribbons) AS ribbons_total, -> SUM(bows) AS bows_total -> FROM -> votes -> GROUP BY -> balloons, soda, ribbons, bows -> ORDER BY -> balloons_total DESC, soda_total DESC, ribbons_total DESC, bows_total DESC; +----------------+------------+---------------+------------+ | balloons_total | soda_total | ribbons_total | bows_total | +----------------+------------+---------------+------------+ | 1 | 1 | NULL | NULL | | 1 | NULL | 1 | 1 | | 1 | NULL | 1 | NULL | | 1 | NULL | NULL | 1 | +----------------+------------+---------------+------------+ 4 rows in set (0.00 sec)
  16. Modify the HTML: Add additional countdown containers with unique IDs. Modify the JavaScript: Update the initializeClock function to accept a unique id for each countdown. Update the fetchRoutine function to fetch data for multiple countdowns and initialize clocks accordingly. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Countdown Clock</title> <link rel="stylesheet" href="reset.css"> <link rel="stylesheet" href="countdown.css"> </head> <body> <div class="info"> <h1 id="display_title"></h1> <h2 id="countdown_date"></h2> </div> <div id="countdown_container1" class="countdown-container"> <div id="display_clock1"> <figure class="box"> <div class="days"></div> <figcaption>Days</figcaption> </figure> <figure class="box"> <div class="hours"></div> <figcaption>Hours</figcaption> </figure> <figure class="box"> <div class="minutes"></div> <figcaption>Minutes</figcaption> </figure> <figure class="box"> <div class="seconds"></div> <figcaption>Seconds</figcaption> </figure> </div> </div> <div id="countdown_container2" class="countdown-container"> <!-- Another countdown container can be added here --> </div> <script src="countdown.js"></script> </body> </html> In the JavaScript (countdown.js), you would modify the functions accordingly: const initializeClock = (containerId, clockId, endtime) => { const clock = document.getElementById(clockId); if (!clock) { console.error(`Clock with id '${clockId}' not found.`); return; } const fields = ['days', 'hours', 'minutes', 'seconds'].map(field => clock.querySelector(`.${field}`) ); if (fields.some(element => element === null)) { console.error('One or more clock elements not found:', fields); return; } const updateClock = () => { const { total, days, hours, minutes, seconds } = getTimeRemaining(endtime); [days, hours, minutes, seconds].forEach((val, i) => { fields[i].textContent = String(val).padStart(2, '0'); }); if (total <= 0) { clock.textContent = "Contest Finished, entry time expired"; clearInterval(timeInterval); } }; updateClock(); const timeInterval = setInterval(updateClock, 1000); }; const fetchRoutine = () => { fetch('data.json') .then(response => response.json()) .then(data => { document.getElementById("countdown_date").textContent = data.date_format; document.getElementById("display_title").textContent = data.title; initializeClock("countdown_container1", "display_clock1", new Date(Date.parse(data.time_left))); // Initialize additional countdowns here if needed }) .catch(error => { console.error('Fetch error:', error); }); }; document.addEventListener('DOMContentLoaded', fetchRoutine); With these modifications, you can add multiple countdown containers to your HTML, and the JavaScript will handle initializing countdowns for each container separately based on the fetched data. Best Regard danish Hafeez | QA Assistant https://www.ictinnovations.com https://www.ictbroadcast.com
  17. You can definitely achieve this directly with SQL using the SUM() function along with GROUP BY and ORDER BY. Here's a basic example of how you could structure your SQL query: SELECT SUM(balloons) AS balloons_total, SUM(soda) AS soda_total, SUM(ribbons) AS ribbons_total, SUM(bows) AS bows_total FROM votes GROUP BY balloons, soda, ribbons, bows ORDER BY balloons_total DESC, soda_total DESC, ribbons_total DESC, bows_total DESC; This query will sum up the votes for each item (balloons, soda, ribbons, bows) separately, grouping them by their respective columns, and then order the results in descending order based on the total votes for each item. You don't need to put the summed data into an array and sort it separately in your code; SQL can handle the sorting and aggregation for you. Best Regard Danish hafeez | QA Assistant ICTInnovations
  18. n PHP, to call a static method, you should use the class name directly followed by ::, like ClassName::method(). Non-static methods are called on an instance of the class using the arrow operator (->). Since show() is a static method, you should call it directly from the class without creating an instance of the template class. So your call should look like this: $content = template::show($m1::$m2()); However, your error suggests that $m1::$m2() is not returning a valid class name. Ensure that $m1 is a class name and $m2 is a static method of that class. If you intend to call a static method of a class stored in a variable, you can use call_user_func() or call_user_func_array() like this: $content = call_user_func(array($m1, $m2)); Or directly: $content = $m1::$m2(); Make sure that $m1 holds the name of a class and $m2 holds the name of a static method of that class. Best Regard Danish hafeez | QA Assistant ICTInnovations
  19. I take it there's a class called 'frontpage' with a non-static method called 'index'?
  20. Here's a countdown clock that I did years ago, but I recently updated it a couple of months ago. countdown.js file "use strict"; /** * Calculates the time remaining until a specified end time. * @param {string} endtime - The end time in a format parseable by Date.parse. * @returns {object} An object containing the total milliseconds and the breakdown in days, hours, minutes, and seconds. */ const getTimeRemaining = (endtime) => { const total = Date.parse(endtime) - Date.now(); // Calculate the difference in milliseconds from now to the end time return { total, days: Math.floor(total / (1000 * 60 * 60 * 24)), // Convert milliseconds to days hours: Math.floor((total / (1000 * 60 * 60)) % 24), // Convert milliseconds to hours, modulo 24 minutes: Math.floor((total / 1000 / 60) % 60), // Convert milliseconds to minutes, modulo 60 seconds: Math.floor((total / 1000) % 60) // Convert milliseconds to seconds, modulo 60 }; }; /** * Initializes a countdown clock on the webpage. * @param {string} id - The ID suffix of the countdown clock container. * @param {Date} endtime - The countdown end time. */ const initializeClock = (id, endtime) => { const clock = document.getElementById(`display_clock${id}`); // Access the clock element by ID if (!clock) { console.error(`Clock with id 'display_clock${id}' not found.`); return; // Exit if no element is found } // Map each time unit to its corresponding DOM element within the clock container const fields = ['days', 'hours', 'minutes', 'seconds'].map(field => clock.querySelector(`.${field}`) ); if (fields.some(element => element === null)) { // Check if any elements are missing console.error('One or more clock elements not found:', fields); return; // Exit if missing elements are found } // Updates the countdown clock display every second const updateClock = () => { const { total, days, hours, minutes, seconds } = getTimeRemaining(endtime); // Update each field in the DOM with the new time [days, hours, minutes, seconds].forEach((val, i) => { fields[i].textContent = String(val).padStart(2, '0'); // Format with leading zeros }); if (total <= 0) { clock.textContent = "Contest Finished, entry time expired"; clearInterval(timeInterval); // Stop the timer if the countdown is complete } }; updateClock(); const timeInterval = setInterval(updateClock, 1000); // Set the timer to update every second }; /** * Fetches the countdown data and initializes the clock using that data. */ const fetchRoutine = () => { fetch('data.json') // Fetch the countdown data from a local JSON file .then(response => response.json()) .then(data => { document.getElementById("countdown_date").textContent = data.date_format; // Set the formatted date document.getElementById("display_title").textContent = data.title; // Set the event title initializeClock(1, new Date(Date.parse(data.time_left))); // Initialize the clock with the fetched data }) .catch(error => { console.error('Fetch error:', error); // Log any errors during fetch }); }; // Ensure all DOM content is loaded before executing the fetch routine. document.addEventListener('DOMContentLoaded', fetchRoutine); it pulls in data from data.json file { "time_left": "2024-08-27T11:59:59-04:00", "date_format": "Tuesday - August 28, 2024", "title": "Countdown to " } here is the HTML file: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Countdown Clock</title> <link rel="stylesheet" href="reset.css"> <link rel="stylesheet" href="countdown.css"> </head> <body> <div class="info"> <h1 id="display_title"></h1> <h2 id="countdown_date"></h2> </div> <div id="display_clock1"> <figure class="box"> <div class="days"></div> <figcaption>Days</figcaption> </figure> <figure class="box"> <div class="hours"></div> <figcaption>Hours</figcaption> </figure> <figure class="box"> <div class="minutes"></div> <figcaption>Minutes</figcaption> </figure> <figure class="box"> <div class="seconds"></div> <figcaption>Seconds</figcaption> </figure> </div> <script src="countdown.js"></script> </body> </html> and even the css file countdown.css *{ -webkit-box-sizing: border-box; box-sizing: border-box; } div.info { display: block; width: 100%; max-width: 300px; height: auto; text-align: center; padding: 2px; margin: 10px auto; } div.info::after { content: ''; display: block; clear: both; } h1 { font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif; font-size: 1.2em; line-height: 1.5; } h2 { font-family: Arial, Helvetica, sans-serif; font-size: 1.0em; font-style: italic; font-weight: 300; } div#display_clock1 { display: block; width: 100%; max-width: 190px; height: auto; margin: 5px auto; background-color: pink; } div#display_clock1 figure.box { float: left; display: block; width: 100%; max-width: 40px; height: 70px; color: #fff; text-align: center; padding: 0; margin-left: 5px; } div#display_clock1 figure.box div { background-color: #2e2e2e; height: 50px; line-height: 50px; } div#display_clock1 figure.box figcaption { font-family: Arial, Helvetica, sans-serif; font-size: 0.6em; line-height: 20px; font-weight: bold; color: #000; } It's a simple countdown clock, but can be modify to enhance. I did check it out that it still runs properly. Fetching the clock can be modify to add even more countdown counters by the `id` in this example there is only 1.
  21. I'm trying to workout the logic before writing my code and I've hit a bump. I'm setting up a table to receive votes and want to display the rankings. Example: what's the best party item? Each row will correlate to the person that submitted a vote. The essential columns would be balloons, soda, ribbons, bows. Voting for an item would INSERT a "1" (unless you're of a certain political party. LOL) into a cell. Now, I want to SUM() each column [I think I can do that] and list them in descending order. Can I do this in a statement? Or do I need to put the summed data into an array and then sort the array? What's the best approach?
  22. Hi all, need some help converting some old code I ran years ago This is the class I am calling:- class template { public static $vars = array(); public static function show($tpl_path) { extract(self::$vars, EXTR_OVERWRITE); ob_start(); include $tpl_path; $cont = ob_get_contents(); ob_end_clean(); return $cont; } This is it being called # new template instance $basetemplate = new template(); $m1 = 'frontpage'; $m2 = 'index'; $content = template::show($m1::$m2()); Standard error i'm getting is Fatal error: Uncaught Error: Non-static method Changing $content = $basetemplate->show($m1::$m2()); doesn't solve it. Any thoughts or suggestions? Many thanks all
  23. It seems like you're almost there! Your code looks good, but there are a few adjustments needed to properly update the countdown timer in your HTML. // Main function to update countdown timer function updateCountdown() { // Calculate the time difference between now and the ending date let difference = endingDate.getTime() - new Date().getTime(); // Check if the difference is valid if (difference <= 0) { console.log("Contest Finished, time expired"); let expiredContest = "Contest Finished, entry time expired"; document.getElementById("expired").textContent = expiredContest; } else { // Calculate days, hours, minutes, and seconds let days = Math.floor(difference / (1000 * 60 * 60 * 24)); let hours = Math.floor((difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); let minutes = Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60)); let seconds = Math.floor((difference % (1000 * 60)) / 1000); // Update HTML elements with the calculated values document.getElementById("daysleft").textContent = days; document.getElementById("hoursleft").textContent = hours; document.getElementById("minutesleft").textContent = minutes; document.getElementById("secondsleft").textContent = seconds; // Schedule the next update after 1 second setTimeout(updateCountdown, 1000); } } // Call the updateCountdown function to start the countdown updateCountdown(); With these changes, your countdown timer should update every second, displaying the correct values for days, hours, minutes, and seconds until the contest ends. Let me know if you have any questions or encounter any issues! Best Regard Danish Hafeez | QA Assistant ICTInnovations
  24. If you're encountering issues with $_SERVER['DOCUMENT_ROOT'] not pointing to the correct directory when moving your files to a web server, you might need to adjust your approach. One common method to ensure that your file paths are consistent across different environments is to define a base directory constant in your application. define('BASE_DIR', dirname(__FILE__)); This line of code sets the constant BASE_DIR to the directory of the current script. You can then use this constant to build your file paths reliably: $assets_path = BASE_DIR . '/assets/'; $includes_path = BASE_DIR . '/includes/'; Alternatively, you can use relative paths to access files within your project. For example: $assets_path = 'assets/'; $includes_path = 'includes/'; In either case, once you have the base directory or relative paths defined, you can access files inside subfolders using concatenation: $module1_file = $includes_path . 'module1/module1_subfolder1/file.php'; $module2_file = $includes_path . 'module2/module2_subfolder1/file.php'; i hope This approach should help you maintain consistent file paths across different environments. Best Regard Danish hafeez | QA Assistant https://www.ictinnovations.com https://www.ictbroadcast.com
  25. 1. Example On my computer <?php include $_SERVER['DOCUMENT_ROOT'].'/assets/filename.php';?> works in localhost 2. When i upload files to webserver in " public_html " it is throwing error warning file doesnot exist in websitename/private_html/assets/filename.php
  26. It's not clear exactly what some paths are here. On your computer, does http://localhost/assets work? Does your-website.com/assets work? And I'm not sure what "private_html" is. Do you mean "public_html"?
  27. There's any number of things that could be problematic but that "error" is specifically a "warning". In general warnings are things you might need to be aware of, but don't rise to the level of an actual runtime error. The line you think is 68 doesn't run a mysqli query, so that is not the source of the problem. Given the offset of the errors it looks like it's the INSERT statement inside the loop that is failing. Other queries to follow that try to truncate the database and insert into the control table also fail. This error tends to be associated with trying to use a mysql connection that isn't open or was open and then closed by erroneous code. Since you left out some code, it's hard to be certain, but an educated guess makes me think that the database connection is failing, since you never check in this line: $connect = new mysqli($servername, $username, $password, $dbname); You should check that with: if (!$connect = new mysqli($servername, $username, $password, $dbname)) { echo "<p>Could not connect to the database</p>"; }
  1. Load more activity
×
×
  • 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.