mysql - Accessing Data VIA PDO within a function - PHP -


I am quite new to PHP, so I apologize in advance for posting any bad code. .

I have created a basic membership system for a fitness bootcamp. I have two SQL table- "member" and "payment".

I have created a table, and using a loop, I can display all the members. Now, I want to be able to check that the member paid the payment using the checkpay ().

This function sees the payment table whether payment is made for that member ID near that line, within the current month and year.

Even when payment is entered in the payment table, the user still shows up as unpaid.

  Function check payment ($ member, $ month, $ year) {global $ db; $ Payment = "Select * FROM 'payment' WHERE member_id =: memberid"; $ Result = $ db- & gt; Ready ($ payment); $ Result-> Beyond Parm (': Member', $ Member, PDO :: Paramax); $ Result-> Beyond Parm (': Month', $ Month, PDO :: Paramatti); $ Result-> Beyond Parm (': year', $ year, PDO: Paramatti); Return result-> Fetch column (); } Code   

Here is the code to display:

  foreach ($ db-> query ('SELECT * FROM' members') As $ line) {$ checkpayment = checkpayment ($ line ['id'], 10,2014); If (! $ Checkpayment) {$ status = "danger"; $ Paid = "unpaid"; } And {$ status = "success"; $ Paid = "paid"; } Echo & lt; Tr class = "'. $ Status.'" & Gt; & Lt; TD & gt; '. $ Line ['id']. '& Lt; / Td> & Lt; TD & gt; '. $ Line ['first_name'] '& lt; / TD & gt; & Lt; TD & gt; '. $ Line ['last_name']. '& Lt; / Td> & Lt; TD & gt; '. $ Paid '& lt; / TD & gt; & Lt; TD & gt; '. $ Line ['program'] '& lt; / TD & gt; & Lt; / TR & gt; '; }   

However, even when a payment line is present, members are still not paid ...

If you are using the ready function, then you should use execute () As far as I know. Try below, if not working, then I will update.

You can see some details about the check payment form ($ member, $ month, $ year) {code> execute ()

  Global $ db; $ Payment = "Choose * Payments from WHERE member_id =: Member"; $ Result = $ db- & gt; Ready ($ payment); $ Result-> Beyond Parm (': Member', $ Member, PDO :: Paramax); $ Result-> carry about (); // ADD This line returns $ result-> Fetch column (); }    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -