htmlkeuzelijst php

Gestart doorPropje13 reacties39 weergaven

14 berichten · pagina 1 van 1

Propje

Lid · Topicstarter

Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

ik ben bezig met mijn adminpaneel en ik wil dus in de htmlkeuzelijst dat ik alle leden uit de db kan selecteeren het is dus me gelukt om het script te gaan scripten. Er is iets dat die maar 2 leden in de keuzelijst zet confused maar er zit meer leden in de db? Hier het script wat ik heb gescript:

$sql = mysql_query("SELECT gebruikersnaam FROM leden") or die(mysql_error());
        $fetch = mysql_fetch_assoc($sql);
        if($fetch == 0){echo"Je hebt geen lid geselecteerd";}
        else{
        echo"Leden: <select name=lid><option></option>";
        while($zoek = mysql_fetch_array($sql)){ echo"<option value=$zoek[0]>$zoek[0]</option>";}
        echo "</select>";


iemand enige idee hoe dat kan ? bloos
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Probeer dit eens:

[COLOR= #0000BB]<?php

$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT gebruikersnaam FROM leden"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fetch[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]))
            {[/COLOR]
                
                [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je hebt geen lid geselecteerd[/COLOR][COLOR= #007700];
                
            }[/COLOR]
            
               [URL="http://www.php.net/else"]else[/URL]
                [COLOR= #007700]{[/COLOR]
            
                    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Leden: <select name=lid>[/COLOR][COLOR= #007700];[/COLOR]
        
                    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$gebruikers[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]))
                        {[/COLOR] 
                    
                            [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<option value=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$zoek[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</option>[/COLOR][COLOR= #007700];
        
                        }
        
                }[/COLOR]
            
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</select>[/COLOR][COLOR= #007700];[/COLOR]
        
?>
0
Propje

Lid · Topicstarter

Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@Josnl

dan krijg ik de htmlkeuzelijst niet te zien.
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
er is geen $fetch

if(mysql_num_rows($fetch == 0))
            {
                
                echoJe hebt geen lid geselecteerd;
                
            }
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oeps, dat stukje had ik weggehaald bloos
[COLOR= #0000BB]<?php

$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT gebruikersnaam FROM leden"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]))
            {[/COLOR]
                
                [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je hebt geen lid geselecteerd[/COLOR][COLOR= #007700];
                
            }[/COLOR]
            
               [URL="http://www.php.net/else"]else[/URL]
                [COLOR= #007700]{[/COLOR]
            
                    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Leden: <select name=lid>[/COLOR][COLOR= #007700];[/COLOR]
        
                    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]))
                        {[/COLOR] 

                               [COLOR= #0000BB]$leden[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]];[/COLOR]
                                   
                            [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<option value="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$leden[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"></option>[/COLOR][COLOR= #007700];
        
                        }
        
                }[/COLOR]
            
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</select>[/COLOR][COLOR= #007700];[/COLOR]
        
?>
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT gebruikersnaam FROM leden"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Er zijn geen leden[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Leden: <select name="lid">[/COLOR][COLOR= #007700];[/COLOR]
        
    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700])){[/COLOR] 
                                   
           [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<option value="[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]">[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]</option>[/COLOR][COLOR= #007700];
        
    }[/COLOR]
 
     [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</select>[/COLOR][COLOR= #007700];       
}[/COLOR]
?>


Zal moeten werken, Jos had paar foutjes yummie
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Check mn edit dan eens Niels, wat is daar fout aan?

// behalve de aanhalingstekens bij de valuebloos
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikers[/COLOR][COLOR= #007700]];[/COLOR] [COLOR= #FF8000]// gebruikers = gebruikersnaam[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]))[/COLOR] [COLOR= #FF8000]// == 0 moet achter de )[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<option value=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$leden[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</option>[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// HTML fail, Je sluit de optie niet af + Zet de naam niet neer zegmaar[/COLOR]

?>


E:

<option value=".$leden."></option> // Output: [niks], Zoals hierboven: Naam vergeten
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dat was voor mn edit idd smile
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Zie de E: emo
E: + Er zijn nog wat fails emo
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja zeg dan dat je bedoelt dat het gebruikersNAAM is emo
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
En de num_rows?
0
Propje

Lid · Topicstarter

Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het lukt alleen heb ik weer een andere probleem,

ik wil zeg maar als ik een lid kiez en ik druk op verzend button wil ik informatie uit de sql hebben van het lid alleen heb nu dit:

$sql = mysql_query("SELECT gebruikersnaam FROM leden") or die(mysql_error());
if(mysql_num_rows($sql) == 0){
    echo Er zijn geen leden;
}else{ 
    if (isset($_POST[verzenden])) {
   echo <form method="post" action="">; 
    echo Leden: <select name="lid">;
        
    while($row = mysql_fetch_assoc($sql)){
                                  
           echo<option value=" . $row[gebruikersnaam] . "> . $row[gebruikersnaam] . </option>;
        
    }
 
     echo </select>; 
     echo <input name="naam" type="text" value="[COLOR= #0000BB]<?php $_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]lid[/COLOR][COLOR= #007700]];[/COLOR] ?>"/>;
     echo <input name="verzenden" type="submit" value="Verzenden" />;
     echo </form>;
      
}


alleen krijg ik deze error

Parse error: syntax error, unexpected T_STRING, expecting , or ; in /home/a2829566/public_html/adminbestelling.php on line 122
0
Berichten
9.969
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Propje schreef:
alleen krijg ik deze error

Parse error: syntax error, unexpected T_STRING, expecting , or ; in /home/a2829566/public_html/adminbestelling.php on line 122
Waarom open je php in een echo?

echo <input name="naam" type="text" value="[COLOR= #0000BB]<?php $_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]lid[/COLOR][COLOR= #007700]];[/COLOR] ?>"/>


(lijn 16 in de bovenstaande code in jou post)
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren