JoseN
Members-
Posts
28 -
Joined
-
Last visited
JoseN's Achievements
Member (2/5)
0
Reputation
-
Hello Everyone - I am playing around with some MYSQL and PHP project I have. I ran into a complex problem getting a PHP table filled with data from MYSQL. I will try to explain what I am trying to do: I am trying to do something like this but in PHP. This is my data from MYSQL database. The Table is called Children This is a quick explanation of how each column on the first screenshot should be filled from the database. This code is what I have so far... to be honest i am not sure how to get the totals of rest of the columns. Maybe use I can use subqueries or if statements... not sure! Can you please help me out? $r = mysqli_query($dbc,"SELECT Classrooms.ClassroomName, COUNT(*) AS TotalChildren FROM Children JOIN Classrooms ON Children.classroomID = Classrooms.classroomID GROUP BY Classrooms.ClassroomName");
-
Mmm! I should be focusing in learning PDO then... Thanks a lot for all the help with these hands on practice I am going through.
-
Thanks Barand! I did some research and I knew I needed to use the bind statement and I actually did but I never released that I didn't need to include the cid and mid variables in the execute(). I was adding them in there... Thanks a lot! I am still learning the PHP language and I was not aware of the PDO style. Which one is better to use? PDO or Mysqli?
-
Still not working! It seems everything else is fine but this line... $stmt->execute( [ $cid, $mid ] ); I think the the statement is not executing. I did a small test.. it always return DIDNT WORK. if ($stmt->execute([ $cid, $mid ])) { echo'WORKED'; } else { echo'DIDNT WORK'; }
-
Got it! Thanks! The Process Posted Data example code not working... I tested it and it is not inserting the data into the database table. Not sure if I am doing something wrong. The code goes in the same file right? Before the HTML form...
-
Got it! Question.... why does the query doesn't return anything when running it like this: $res=$dbc->mysqli_query(); it does return data with your example but is it secure? $res=$dbc->query(); Why not running it like this? Just wondering... $res = "SELECT meal_id, description FROM meal ORDER BY meal_id "; mysqli_query($dbc, $res); // Run the query.
-
Great! Thanks Barand! I am still trying to get the table to come show. It is now coming up with your example. I just get a blank page when I run it. The only thing I get is the Submit button.
-
How about this? This is the SELECT query to get the names of the children. $q="SELECT childID, CONCAT(Firstname, ' ' ,Lastname) AS childname FROM Children"; This is the table... echo' <div class="table-responsive"> <table class="table table-hover table-bordered table-sm"> <thead class="thead-dark"> <tr> <th class="text-center" scope="col">Child Name</th> <th class="text-center" scope="col">Breakfast</th> <th class="text-center" scope="col">Lunch</th> <th class="text-center" scope="col">Snack</th> </tr> </thead> <tbody>'; while ($row = mysqli_fetch_array($r)) { // Print out the records echo' <tr> <td>' . $row['childname'] . '</td> <td></td> <td></td> <td></td> </tr>'; } //end of while loop echo' </tbody> </table> </div>
-
Got it! Date for the timestamp! How would I do the table form with the checkboxes? I can't see a way to start it!
-
-
Hello Barand! I need some help again! I am trying to create a table like the attached image. The idea is to have this table with names coming from a users table... then be able to track the meals using checkboxes. The checkboxes checked would then be submitted via a button to a Meals table in MYSQL... I am thinking the table can be mealID, userID (Userstable), Breakfast, Lunch, Snack. The meals can be a tinyint datatype. I totally don't know how to start doing this... Thanks in advance,
-
Thanks Barand! you mean broadcasting it here in the forum? it is just dummy data or you mean other way?
-
Barand - I got it to work using the OnClick button! I was able to pass the userID and rewardID using only one button. Now when i redeem a reward for a specific user, it inserts the reward negative value to the points table just for that single user. The total points column now it looks better. I hope this definitely worked! I will test it later to make sure. I got a different question. Is it possible to hide or encrypt the names of the PHP files in the URL when an user is browsing them? For example, www.domain.com/view_users.php to something like this www.domain.com/tsds$ds.php After redeeming rewards