Jump to content

joe904

New Members
  • Content count

    6
  • Joined

  • Last visited

Community Reputation

0 Neutral

About joe904

  • Rank
    Newbie
  1. Hey Guys, I am trying to fix a PHP page that I am coding for my job. Basically the functionality that I am looking for is a Marquee (Yes I understand the Marquee is done away with in HTML5. I haven't learned to use CSS instead yet) function where the names that I have in my database will scroll from bottom to top in the center of the page. I am a teacher and I am trying to set up a point system to display the points that my kids have earned. I have a MySQL database that has a few fields, such as student ID's, Names, etc. I want to connect my database and have the names and associating information scroll up one after the other on my website. I have some code that I found it online but it didi not work correctly. When it displayed, the entire database showed at once and then disappeared instead of scrolling one at a time. Yes I am a newby at this, so please have patience with me. I have searched online for an answer, and have not been able to find one. So I sdecided to try this forum. Any help is greatly appreciated. <?php $scrolling="true"; //Define if text is scrolling or Still //Config $db_host="localhost"; $db_name="swap"; $db_user="root"; $db_pass="pass"; // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL. Make sure to edit the config.php file: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM students ORDER BY studentId ASC "); while($swap = mysqli_fetch_array($result)) { if ($scrolling == "true"){ //Scrolling Text ?> <html> <h1 class="marquee"><span><b><?php echo $swap['studentId'];?> <?php echo $swap['first_name'];?></b><?php echo $swap['last_name']; ?><</html> <?php } else { //Not Scrolling Text ?><b><?php echo $swap['studentId']; ?> </b>: <?php echo $swap['last_name']; } } ?>
  2. joe904

    Increment Table Variable

    No they are actually the same. The column in my database for where the damage count will be stored is named `damage#` I tried inserting the query but I keep getting an error. <?php if (isset($_POST['student_id'])) { $studentId = $_POST['student_id']; // handle case where we don't get a student id 'UPDATE `students` SET damage# = `damage#` + 1 WHERE `studentId` = ?'; $sql = 'SELECT * FROM `students` WHERE `studentId` = ?'; $stmt = $pdo->prepare($sql); $stmt->bindParam(1, $studentId, PDO::PARAM_INT); $stmt->execute(); $student = $stmt->fetch(PDO::FETCH_ASSOC);
  3. joe904

    Increment Table Variable

    Yes that is correct....Only the student that was entered <!DOCTYPE html> <html lang="en"> <?php include 'connection.php';?> <head> <meta charset="utf-8"> <link rel="shortcut icon" href="images/favicon1.ico"/> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"> <script src="js/jquery-3.3.1.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://unpkg.com/sweetalert2@latest/dist/sweetalert2.all.js"></script> <script src="https://cdn.jsdelivr.net/npm/sweetalert2"></script> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <title>Student Damage Report</title> </head> <style> body { background-image: url("images/back1.jpg"); width: 100%; height: 400px; background-repeat: no-repeat; background-size: contain; } </style> <body> <div class="title1">STUDENT DAMAGE DATABASE</div> <form method="post" id="theFormID" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <div class="form_question"> <center><label>Please Enter Student ID#</label> <input type="text" id="theFieldID" name="student_id" placeholder="" /></p> </div></center> <script type="text/javascript">theFormID.theFieldID.focus();</script></form> <?php if (isset($_POST['student_id'])) { $studentId = $_POST['student_id']; // handle case where we don't get a student id $sql = 'SELECT * FROM `students` WHERE `studentId` = ?'; $stmt = $pdo->prepare($sql); $stmt->bindParam(1, $studentId, PDO::PARAM_INT); $stmt->execute(); $student = $stmt->fetch(PDO::FETCH_ASSOC); if ($student) { ?> <p class="response"><mark>Student ID# <?= $student['studentId']?></mark><br>First Name: <?= $student['first_name']?><br>Last Name: <?= $student['last_name']?><br>Grade: <?= $student['grade']?><br>Gender: <?= $student['gender']?> <br>Student Damage: <?= $student['damage#']?></p> <?php } else { ?> <p class="notification">Student <?php echo $studentId ?> was not found in the database</p> <?php } } ?> <div id="footer"> <div class="w3-container"> <div class="w3-dropdown-click"> <button onclick="myFunction()" class="w3-button w3-black"><img src="images/print.png" width=50px height=50px></button> <div id="Demo" class="w3-dropdown-content w3-bar-block w3-card-4 w3-animate-zoom"> <a href="javascript:window.print()" class="w3-bar-item w3-button">Print Form</a> <a href="records.php" class="w3-bar-item w3-button">Print Database</a> </div> </div> </div> <script> function myFunction() { var x = document.getElementById("Demo"); if (x.className.indexOf("w3-show") == -1) { x.className += " w3-show"; } else { x.className = x.className.replace(" w3-show", ""); } } </script></div> </body> </html>
  4. joe904

    Increment Table Variable

    temp.tecwarrior.com Test ID - 123456 Once an ID is inputted the student info comes up. "Student Damage" should automatically increment +1...Keeping track of damage
  5. joe904

    Increment Table Variable

    I am not sure what I am missing. I am a newbie at this. How would I incorporate this SQL stmt into PHP or HTML? Would I have to do some kind of while loop, or something else? Can you please give me an example if possible.
  6. joe904

    Increment Table Variable

    Hey Guys!!, I am trying to figure out how to write some php code to increment a variable. I am using php version 7.1.2. I have tried looking for sources online to figure it out, but have not been able to find a good how-to. I am trying to run a simple php application that every time it runs, starting with 0 it adds +1 to my 'count' column in my 'students' database. Any help is much appreciated. CREATE TABLE `students` ( `ID` int(11) NOT NULL, `Name` varchar(11) NOT NULL, `count` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `students` (`ID`, `Name`, `count`) VALUES (12345, 'James Smith', 0), (56789, 'Mike Sims', 0);
×

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.