Solved

mysql php

Posted on 2015-02-01
3
38 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:Ron Baas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Ron Baas
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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Creating and Managing Databases with phpMyAdmin in cPanel.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

632 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