Solved

mysql php

Posted on 2015-02-01
3
17 Views
Last Modified: 2016-06-18
Hello I have a problem with mysql.

I want us values from a another table.

This is what I got:

      $q = "SELECT voorbeeld_id, voorbeelden1, voorbeelden2, voorbeelden3, voorbeelden4, voorbeelden5, voorbeeldenfile," .
                                     "             datediff(voorbeelden3, CURDATE()) AS voorbeelden4" .
                                     "  FROM voorbeelden WHERE klant_id = :klant_id" .
                                     "  ORDER BY voorbeeld_id ASC";
                              $sth = $db->prepare($q);
                              $sth->execute(array("klant_id" => $klant_id));


Now I want also from the table "klanten"  the values of "leverancier". I hope someone can help me.
0
Comment
Question by:ronbaas1
3 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 40583132
Do you want both the value from voorbeelden and from klanten in the same query?  How are the tables voorbelden and klanten related?  Do they share a field?  Perhaps klant_id?

If so ... this query should work.  Or be close enough that you can adjust it.
      $q = "SELECT voorbeeld_id, voorbeelden1, voorbeelden2, voorbeelden3, voorbeelden4, voorbeelden5, voorbeeldenfile," .
                                     "             datediff(voorbeelden3, CURDATE()) AS voorbeelden4, leverancier" .
                                     "  FROM voorbeelden inner join klanten on voorbeelden.klant_id = klanten.klant_id
                                        WHERE voorbeelden.klant_id = :klant_id" .
                                     "  ORDER BY voorbeeld_id ASC";
                              $sth = $db->prepare($q);
                              $sth->execute(array("klant_id" => $klant_id));

Open in new window

0
 

Author Comment

by:ronbaas1
ID: 40612837
thanks Daniel its working now with this code:

      $q = "SELECT voorbeeld_id, voorbeelden1, voorbeelden2, voorbeelden3, voorbeelden4, voorbeelden5, voorbeeldenfile,  leverancier," .
                                     "             datediff(voorbeelden3, CURDATE()) AS voorbeelden4" .
                                     "  FROM voorbeelden inner join klanten on voorbeelden.klant_id = klanten.klant_id
                                        WHERE voorbeelden.klant_id = :klant_id" .
                                     "  ORDER BY voorbeeld_id ASC";
                              $sth = $db->prepare($q);
                              $sth->execute(array("klant_id" => $klant_id));
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now