Register for your free account! | Forgot your password?

Go Back   elitepvpers Coders Den Web Development
You last visited: Today at 23:23

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Suche PHP / MYSQL Hilfe

Discussion on Suche PHP / MYSQL Hilfe within the Web Development forum part of the Coders Den category.

Closed Thread
 
Old   #1

 
Givemoney's Avatar
 
elite*gold: 18
The Black Market: 677/0/0
Join Date: Feb 2012
Posts: 28,543
Received Thanks: 1,109
Suche PHP / MYSQL Hilfe

Guten Tag,
ich möchte meine Datenbank ausgabe in einem Dropdown menü machen, das ganze Funktioniert auch soweit, bloß macht er jedesmal ein neues Dropdown menü anstatt eins.
Bild:
Kann mir jemand sagen, wie ich das ganze richtig anspreche.

Code:
PHP Code:
<!DOCTYPE html>
<html>
<head>

</head>
<body>


<?php
$q 
= ($_GET['q']);

$con mysqli_connect('localhost:3307','root','1234','justin');
if (!
$con) {
    die(
'Could not connect: ' mysqli_error($con));
}

mysqli_select_db($con,"ajax_demo");
$sql="SELECT * FROM adress WHERE lastname = '".$q."'";
$result mysqli_query($con,$sql);


while(
$row mysqli_fetch_array($result)) {


  echo 
'<select>';
  echo 
'<option value = ".$row["firstname"]. ">' .$row["firstname"] . " " .$row["lastname"];
  echo 
'</select>';

    }

mysqli_close($con);
?>
</body>
</html>
Mfg

Givemoney
Givemoney is offline  
Old   #2

 
Syc's Avatar
 
elite*gold: 666
Join Date: Apr 2011
Posts: 5,810
Received Thanks: 2,418
Wie sollen wir dir das ohne Code sagen?
Vermutlich ist aber einfach eine for / foreach falsch.
Syc is offline  
Old   #3

 
~ JWonderpig ~'s Avatar
 
elite*gold: 60
Join Date: Sep 2013
Posts: 1,427
Received Thanks: 248
PHP Code:
<select>
        <?php foreach... ?>
</select>
Wahrscheinlich hast du die Select-Tags mit in der Schleife
~ JWonderpig ~ is offline  
Old   #4

 
Givemoney's Avatar
 
elite*gold: 18
The Black Market: 677/0/0
Join Date: Feb 2012
Posts: 28,543
Received Thanks: 1,109
Code:
PHP Code:
<!DOCTYPE html>
<html>
<head>

</head>
<body>


<?php
$q 
= ($_GET['q']);

$con mysqli_connect('localhost:3307','root','1234','justin');
if (!
$con) {
    die(
'Could not connect: ' mysqli_error($con));
}

mysqli_select_db($con,"ajax_demo");
$sql="SELECT * FROM adress WHERE lastname = '".$q."'";
$result mysqli_query($con,$sql);


while(
$row mysqli_fetch_array($result)) {


  echo 
'<select>';
  echo 
'<option value = ".$row["firstname"]. ">' .$row["firstname"] . " " .$row["lastname"];
  echo 
'</select>';

    }

mysqli_close($con);
?>
</body>
</html>
Givemoney is offline  
Old   #5

 
~ JWonderpig ~'s Avatar
 
elite*gold: 60
Join Date: Sep 2013
Posts: 1,427
Received Thanks: 248
So funktioniert es.
PHP Code:
<!DOCTYPE html>
<html>
<head>

</head>
<body>


<?php
$q 
= ($_GET['q']);

$con mysqli_connect('localhost:3307','root','1234','jus tin');
if (!
$con) {
die(
'Could not connect: ' mysqli_error($con));
}

mysqli_select_db($con,"ajax_demo");
$sql="SELECT * FROM adress WHERE lastname = '".$q."'";
$result mysqli_query($con,$sql);



echo 
'<select>';

while(
$row mysqli_fetch_array($result)) {

echo 
'<option value = ".$row["firstname"]. ">' .$row["firstname"] . " " .$row["lastname"];


}

echo 
'</select>';

mysqli_close($con);
?>
</body>
</html>
~ JWonderpig ~ is offline  
Thanks
1 User
Old   #6

 
Givemoney's Avatar
 
elite*gold: 18
The Black Market: 677/0/0
Join Date: Feb 2012
Posts: 28,543
Received Thanks: 1,109
@Jwonderpig danke, für deine Perfekte und Schnelle hilfe.
Givemoney is offline  
Old   #7

 
snow's Avatar
 
elite*gold: 724
Join Date: Mar 2011
Posts: 10,478
Received Thanks: 3,318
#closed (on request)
snow is offline  
Closed Thread


Similar Threads Similar Threads
[PHP] Suche PHP OOP MYSQL Hilfe
07/19/2015 - Web Development - 17 Replies
Alle Frage, wurde gelöst!!! Danke an alle. Alte Frage Undzwar habe ich mit OOP 2 Klassen erstellt und ich möchte nun das die MYSQL DB verbindung dauerthaft bleibt, also auch in der 2 Klasse sonst funzt mein Insert befehl nicht. Leider bekommt die 2 Klasse keine verbindung. Wie stelle ich das an? wäre nett wenn mir jemand helfen könnte. <?php
Suche Hilfe mit Mysql Verbindung
11/10/2013 - .NET Languages - 7 Replies
Hi, ich hab ein login/registrier system das über mysql läuft, aber ich bekomme immer den fehler das keine verbindung zum mysql serever hergestellt werden konnte, könnte mir wer helfen? login code Dim conn As MySqlConnection conn = New MySqlConnection conn.ConnectionString = "server=xxx;" & "user=xxx;" & "password=xxx;" & "database=xxx" Try
Suche Hilfe Mysql!
03/29/2013 - Metin2 Private Server - 1 Replies
Hallo. Wie gesagt bekomme ich diese fehler ! http://www.fotos-hochladen.net/uploads/unbenannt3 tsk54azqy.png Wer könnte mir da helfen bitte ?
Suche Hilfe für MySQL
04/25/2012 - Metin2 Private Server - 6 Replies
Hey Leute , n Kumpel und ich haben vor uns nen eigenen P-Server zu erstellen. Es hat soweit auch alles schon recht gut geklappt. Es ist zu Testzwecken erstmal nur ein Homeroot. Diesen hat er auf seinem Pc erstellt. Da wir aber beide bisschen dran rumbasteln wollen muss ich auch auf die MySQL Datenbank zugreifen können. Meine Frage also nun .. Wie ?! :mad: Hatte zwar schon n Programm (easycontrol) aber das funzte iwie mal gar nicht.. Ich hoffe nun auf eure Unterstützung.
MySql suche hilfe !
10/08/2010 - Metin2 Private Server - 3 Replies
Warning: mysql_connect() : root connections are not allowed on in /usr/export/www/vhosts/funnetwork/hosting/crankmet in/dateien/scripts/admin/pages/main.htm on line 5 ERROR: Connection failed. Das kommt auf meiner Hp auf meinem DynDns server was muss ich tuhen wäre nett wen ihr mir helfen würdet Edded mich bei skype : max199495 oder schreibt hier gebe 10€ paysafe wenn es klappt ! danke :handsdown:



All times are GMT +2. The time now is 23:25.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.