Jump to content

I-AM-OBODO

Members
  • Posts

    442
  • Joined

  • Last visited

Contact Methods

  • AIM
    funkyfel
  • MSN
    funkyfela
  • Yahoo
    funkyfela
  • Skype
    chidi.james

Profile Information

  • Gender
    Male
  • Location
    Nigeria
  • Interests
    Computer, Playing Video Games, Learning

Recent Profile Visitors

7,785 profile views

I-AM-OBODO's Achievements

Advanced Member

Advanced Member (4/5)

1

Reputation

1

Community Answers

  1. Hi Does anyone know how I can connect a thermal printer from my Samsung tab to print to the printer? The printer is not a Bluetooth printer. It is connected to the system via a cable. I have checked and it seems the printer does not have an ip address either. Was thinking I could connect via the system ip address when shared. I have tried many android app including printshare and mobiprint rawbt but I wasn't able to connect the printer to the tab. I don't know if I was doing something wrong though. If any has done something like that, please I'd like to know. Thanks
  2. Hello Please how can i see my threads from way back? i could only see from 2023 Thanks
  3. I Guest that's why! Funny though! Was using InnoDB before now. Had to switch cos a functionality I needed will only be possible with MyISAM and now another function can only work in InnoDB. 😆 Guess that's life! Nothing and no one has everything. Just gotta do with what's paramount. Thanks 😊
  4. I am very very sure the data are not identical and the query from the first query is entered. I did that several times. I am baffled myself.
  5. Hello all. I am playing with transaction and i noticed something. I deliberately omitted txn in my second mysql statement. the first statement went through i.e the data were stored regardless of the error thrown by transaction: why was it so? why did the query execute? was thinking no entry is supposed to pass through should there be any error with transaction? below my code try { $pdo->beginTransaction(); $sql = "INSERT INTO tbl_cont_asess_records ( txn, subj_id, test_score, exam_score ) VALUES ( ?, ?, ?, ? )"; $stmt = $pdo->prepare($sql); foreach(array_column($subject_data,'id') as $key) { $stmt->execute([ $txn, $key, $post['test_score'][$key], $post['exam_score'][$key] ]); } $sql2 = "INSERT INTO tbl_cont_asess ( txn, sch_session, sch_term, ward_id, class_id, staff_id ) VALUES ( ?, ?, ?, ?, ?, ? )"; $stmt2 = $pdo->prepare($sql2); $stmt2->execute([ $current_session, $current_term, $_GET['id'], $class_id, $staff_id ]); $pdo->commit(); echo '<div class="alert alert-success text-center text-dark">Scores Saved SUCCESSFULLY!</div>'; }catch (PDOException $e) { $pdo->rollBack(); echo '<div class="alert alert-danger text-center">Score Not Saved. Problem Occurred!</div>'; }
  6. I've been able to do the minus from within the query now. After everything, the working query is SELECT t1.customer_id, t1.customer_name, COALESCE(t2.total_sales, 0) as total_sales, COALESCE(t3.amt_paid, 0) as amt_paid, COALESCE(t2.total_sales, 0) - COALESCE(t3.amt_paid, 0) as to_balance FROM customers t1 LEFT JOIN ( SELECT customer_id, SUM(total_price) as total_sales FROM tbl_sales GROUP BY customer_id ) t2 USING (customer_id) LEFT JOIN ( SELECT customer_id, SUM(amt_paid) as amt_paid FROM tbl_sales_total WHERE status = 0 GROUP BY customer_id ) t3 USING (customer_id) HAVING to_balance <> 0 ORDER BY t1.customer_name ASC; Thanks @Barand
  7. The duplicate names I have addressed. All that's left is to know if the minus could be done in the query. Other than that, it's working just fine. Thanks a million times
  8. I have seen why it was throwing error. Its cos of values that are 0. And number_format use with value 0 is deprecated. I have resolved the error issue but the problem now is that the grouping does not working in the final execution of the query. It brings out the new multiple times. How can I fix this. Thanks
  9. It worked fine as expected. Thank you so much. But one other thing is with these joins, how can i use it to get same result but without specifying the customer? When I removed the where clause, it throws an error. I also know I can get the difference between total_sales and amt_paid by first getting the values of each and then minus it. But I am curious to know if it can be achieved using the mysql query? If possible, how can it be done? Thanks so much as always! Besides, how can one know when to use the multi level joins you used? Joins so complicated. Thanks
  10. Hello all. please what could be the reason i am not getting the desired result when i do a JOIN. This query gives the desired result //calculate profit $stmt = $pdo->query(" SELECT SUM(total_cost) AS total_cost, SUM(total_sales) AS total_sales FROM tbl_sales WHERE customer_id = 489639 AND status = 0 "); $row = $stmt->fetch(PDO::FETCH_ASSOC); $total_sales = $row['total_sales']; $total_cost = $row['total_cost']; $profit = $total_sales - $total_cost; //calculate balance $stmt = $pdo->query(" SELECT SUM(amt_paid) AS amt_paid FROM tbl_sales_total WHERE customer_id = 489639 AND status = 0 "); $row = $stmt->fetch(PDO::FETCH_ASSOC); $amt_paid = $row['amt_paid']; $balance = $total_sales - $amt_paid; echo "<strong>Total Profit Realised From Customer: ₦".$profit."</strong>"; echo "<br><strong>Total Unpaid Balance: ₦".$unpaid_bal."</strong>"; But when i do a join it gives a wrong result. $stmt = $pdo->query(" SELECT *, SUM(t2.total_price) AS total_sales, SUM(t3.amt_paid) AS amt_paid FROM customers t1 LEFT JOIN tbl_sales t2 ON t1.customer_id = t2.customer_id LEFT JOIN tbl_sales_total t3 ON t1.customer_id = t3.customer_id WHERE t1.customer_id = 489639 AND t3.status = 0 "); WHILE($row = $stmt->fetch(PDO::FETCH_ASSOC)){ echo '<tr> <td>'.$row["customer_name"].'</td> <td>'.$row["total_sales"].'</td> <td>'.$row["amt_paid"].'</td> </td> </tr>'; } Please what did i do wrong and how do i get the desired result. Thanks
  11. Thanks for the response. You've shed more light on the topic for me. I will do more research on provisioning. At least I know the name of what I will be researching about! Though I know all about creating a subdomain for them and setting up the database base etc. But I want it automated without me doing a thing. They should just fill form and voilà! It created. Thanks for the tips!
  12. Thanks for your reply. But you don't get what I am trying to convey cos I might have not conveyed it proper. But your explanation is way different from what I am asking of! I know all about my account with with phpfreak ans all that cos I have built app and websites with such privileges and user areas but this is totally different from my question. Gizmola has a better understanding for my question. Provisioning is word for it. I have perused through an web app that does what I want and I know it's quite different from what I'm used to. I can manually set up each account I know. I also know that I can create a subdomain for for each store and create different database for each of them. I know all these. But it's totally different from the question I asked. On this Web app that I want to copy, I visited, filled my choice name and filled some forms based on my own likings and what the form requires. After filling the form and submit, a subdomain was created automatically for me with all the basic database settings so that when I am logged in, I can complete the setting and my profile as per my requirements. Hope you get a better picture and know that it's way different from what you said or the analogy between me creating an account on phpfreaks and all that. Thanks for the response though. I appreciate it
  13. Hello guys. I really don't know what to use as a topic and my question might no be clear enough cos I might lack adequate words to put it together but I will try by using examples anyhow. My question is Like during joomla or WordPress installation, the processes one has to undergo e.g filling the company/application name, database name, admin username and password, color scheme etc. In like manner, one has a web app hosted. How to enable different user create their own account and setup their database etc For example I have a web app hosted at https://myapp.com A user can setup their shop on my app https://myapp.com/shop1 or shop1.myapp.com Hope I tried to make it clear enough Thanks
  14. Thank you for your responds and list of dos/don'ts. Will take note of them. But still didn't solve my problem. If I don't use a modal for the form, I can check for duplicate and display the error. The problem I am having is displaying the duplicate error inside the modal. As for ids, they are required for the modal to work. The id passes values of the form to the database. That's how the code for the modal was built. The alter table is temporal. No. I am not outputting the database errors live. I am not really a fan of placeholders. I have a function that trims inputs for validation. Good to know about the ucword/strtoupper. But is there a reason why it should be on output and not during save? Just curious to know. Overall, the observations are very useful and I have learned a few things that I will adapt to. If, I can't get a way to display the errors inside the modal, I guess I will just change the design and not use modal for the form. Thanks
×
×
  • 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.