Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About rec0il

  • Rank
  1. Hello, I'm trying to create a code that can help me and my friend keep track on how much weight we have used in past workouts and update it regularly while at the gym. To visualise what I'm trying to create, here is a link to the design. Click me I'm not very good at php coder nor SQL, so it's pretty difficult for me, but I've tried to create the code for the whole design but I'm stuck and can't figure out how to create the rest, I was hoping someone could help me. What I'm trying to achieve; To have the name of whoever using it at the top. To have the dropdown menu automaticly generated from my database To have it show the current weight on the selected exercise Be able to update the weight fast and easy What I have so far is <?php include ("connect.php"); $sql = "SELECT * FROM `workout` WHERE exercise='dumbell bench press'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<br> Ali: ". $row["Ali"] . "<br> Emil: ". $row["Emil"] . "<br><br>" ; } } else { echo "0 results"; } function updater($value,$id){ include ("connect.php"); $value=mysqli_real_escape_string($conn,$value); $id=mysqli_real_escape_string($conn,$id); $sql = "UPDATE `workout` SET Ali='{$value}' WHERE exercise='{$id}'"; if ($conn->query($sql) === TRUE) { header("Refresh:0"); } else { echo "Error updating record: " . $conn->error; } $conn->close(); } if (isset($_POST['Ali'])) updater($_POST['Ali'],$_POST['id']) ?> <html> <body> <?php include ("connect.php"); $sql = "SELECT exercise FROM `workout`"; $result = $conn->query($sql); if ($result->num_rows > 0) { $select= '<select name="select">'; // output data of each row while($row = $result->fetch_assoc()) { $select.='<option value="'.$row['exercise'].'">'.$row['exercise'].'</option>'; } } else { echo "rest in peace"; } $select.='</select>'; echo $select; ?> <br><br> <form action="" method="post" style="height:50px;width:50px;"> <input type="hidden" name="id" value="dumbell bench press" /> <input type="text" name="Ali" /><br><br> <input type="submit" /><br/> </form> </body> </html> Where I've created my database like so: http://i1227.photobucket.com/albums/ee433/rec0ill/12312321_zpsbkamhfry.png
  • 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.