mysql_query , selecteert niet alles!

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Senior, Medior and Junior SAP HANA Developer

Vacature details Vakgebied: Software/IT Opleiding: Medior Werklocatie: Veldhoven Vacature ID: 12696 Introductie Our client is the world's leading provider of lithography systems for the semiconductor industry, manufacturing complex machines that are critical to the production of integrated circuits or chips. Our purpose is “unlocking the potential of people and society by pushing technology to new limits”. We do this guided by the principles “Challenge”, “Collaborate” and “Care”. Wat verwachten we van jou? SAP Certified Application Associate - SAP HANA Cloud Modeling (training and/or certification) Bachelor degree or higher Excellent understanding of SAP HANA (2.0 / Cloud), Data Modelling and writing

Bekijk vacature »

Tom aan t Goor

Tom aan t Goor

14/07/2011 14:01:20
Quote Anchor link
Ik heb de volgende regels:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
$zieksel = mysql_query("SELECT * FROM `ziekenhuis` WHERE `klant`='$naam'");
$ziek = mysql_fetch_object($zieksel);


nu wil ik dat hij alles selecteert waar klant je naam is.
Nu is het probleem, ik sommige namen, komen vaker voor als klant, maar dan selecteert hij er maar 1.
Hoe kan ik zorgen dat hij ze dan allemaal selecteert waar klant, $naam is?
 
PHP hulp

PHP hulp

19/04/2024 15:45:42
 
Mark L

Mark L

14/07/2011 14:26:59
Quote Anchor link
Het probleem zit 'm niet in de SQL. Deze selecteert alle klanten met die naam.
De variabele $ziek krijgt enkel de éérste klant. Dus als je $ziek2 = mysql_fetch_object($zieksel) zou doen, krijg je de volgende etc.

Om het eenvoudiger te maken:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
<?php
    $zieksel
= mysql_query("SELECT * FROM ziekenhuis WHERE klant = '" . $naam . "'");
    while ($row = mysql_fetch_assoc($zieksel))
    {

        echo $row['kolomnaam'];
    }

?>


Ik denk dat je er hiermee uit moet komen.
 
Kevin Ellen

Kevin Ellen

14/07/2011 16:06:06
Quote Anchor link
Tom, ga af van de 'backticks' (deze dingen: `). Die zijn onnodig en kunnen alleen fout gaan.
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.