dj on air

Gestart doorFreestyle1 reacties17 weergaven

2 berichten · pagina 1 van 1

Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb een script gemaakt maar hij doet het nog niet.

Ik wil dat er steeds 1 dj online is. en dat je kan kiezen welke dj dat is.
Als hij status 1 heeft dan zie je zijn naam. heeft hij status 0 dan zie je hem niet.
het is al gelukt om ze goed uit de tabel te halen. maar het lukt mij niet om ze aan te passen naar een ander.

code:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM online WHERE status=1"[/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]$result[/COLOR][COLOR= #007700]))
{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]dj[/COLOR][COLOR= #007700]];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];[/COLOR]


[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<hr />[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]sumbit[/COLOR][COLOR= #007700]])
    {[/COLOR]
    
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE online SET status = 0
                    WHERE dj = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]dj[/COLOR][COLOR= #007700]] .[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
    
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE online SET status = 1
                    WHERE dj = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]dj[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]);
    }
}[/COLOR]
?>
<form action="" method="POST">
<p>
<label>DJ:</label>
<select value="dj" name="dj">
<option value="Dave Gerrits" name="dave">Dave Gerrits</option>
<option value="Frido" name="friode">Frido</option>
<option value="Peter vd Wal" name="peter">Peter vd Wal</option>
<option value="Eddy" name="eddy">Eddy</option>
<option value="OFF AIR" name="off">Off AIR</option>
</select>
<input type="submit" name="sumbit" />
</p>
</form>


Ik weet ook niet goed wat ik bij de "name" moet invullen.
alvast bedankt
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
even naar de php gekeken en het een en ander als commentaar erbij gegeven.

LET goed op strings die je zomaar in de database propt.

[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]# Include config.[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #FF8000]# MySQL query om gegevens eruit te halen.[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
                SELECT 
                    * 
                FROM 
                    `online` 
                WHERE 
                    status = 1
                "[/COLOR][COLOR= #007700]);[/COLOR]

    [COLOR= #FF8000]# while loop om de gegevens te laten zien door bijvoorbeeld echo $row[iets];[/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]$result[/COLOR][COLOR= #007700])) {[/COLOR]
        
        [COLOR= #FF8000]# De DJ uit de tabel[/COLOR]
        [COLOR= #0000BB]$tabeldj[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]dj[/COLOR][COLOR= #007700]];
        
    }[/COLOR]

    [COLOR= #FF8000]# Als er een request komt, oftewel iemand drukt op submit.[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]sumbit[/COLOR][COLOR= #007700]])) {[/COLOR]
        
        [COLOR= #FF8000]# Je kan ook doen:
        # if($_SERVER[REQUEST_METHOD] == "POST") {
    
        # MySQL query om de DJ zijn status op 0 (nul) te zetten van de djs uit de tabel (database).[/COLOR]
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
                UPDATE 
                    `online` 
                SET 
                    status = 0
                WHERE 
                    dj = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tabeldj[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]"
                "[/COLOR][COLOR= #007700]);[/COLOR]
    
        [COLOR= #FF8000]# MySQL query om de DJ zijn status op 1 te zetten van de gepost DJ, oftewel de DJ die in wil loggen.[/COLOR]
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
                UPDATE 
                    `online` 
                SET 
                    status = 1
                WHERE 
                    dj = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]dj[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]"
                "[/COLOR][COLOR= #007700]);
                
    }[/COLOR]

?>
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