Javascript echoën met PHP

Gestart doorAndydewit16 reacties31 weergaven

17 berichten · pagina 1 van 2

Andydewit

Lid · Topicstarter

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

Kan je javascript met PHP echoën?
dus zoiets:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<script type="text/javascript">[/COLOR][COLOR= #007700];[/COLOR]
?>


Want als ik dat doe, dan werkt hij namelijk niet. Tevens geeft hij ook geen fouten.
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dat kan dus wel? confused
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
en wat heeft het voor praktisch nut ? emo
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sjoerd schreef:
en wat heeft het voor praktisch nut ? emo
mischien dat hij diverse variabelen uit php er in wilt verwerken
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
dan kan je ook tussen door doen
0
Andydewit

Lid · Topicstarter

Berichten
1.168
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb verschillende dingen die ik uit de database wil halen, dus dan moet het steeds herhaald worden. Alleen hij werkt niet.
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Laat de code dan eens zien?
0
Andydewit

Lid · Topicstarter

Berichten
1.168
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/*
Copyright Andy de Wit
Niemand mag deze code overnemen zonder toestemming van de maker.
*/[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM domeinen"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$rows[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
?>
<head>
<script type="text/javascript">
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]function domein(dnaam) {[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]var dnaam = dnaam;[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]for (i=1;i<=<?=$rows?>;i++) {[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]document.getElementById(domein+i).value = dnaam;[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]}[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]}[/COLOR][COLOR= #007700];[/COLOR]
?>
</script>

<script type="text/javascript">
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/for"]for[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]<=[/COLOR][COLOR= #0000BB]$rows[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]var http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] = false;[/COLOR][COLOR= #007700];
}[/COLOR]

[URL="http://www.php.net/for"]for[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]<=[/COLOR][COLOR= #0000BB]$rows[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]var http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] = false;[/COLOR][COLOR= #007700];
}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]if (navigator.appName == "Microsoft Internet Explorer") {[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/for"]for[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]<=[/COLOR][COLOR= #0000BB]$rows[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] = new ActiveXObject("Microsoft.XMLHTTP");[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]} else {[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/for"]for[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]<=[/COLOR][COLOR= #0000BB]$rows[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] = new XMLHttpRequest();[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]}[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]function checkdomain (url) {[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$r[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])) {[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000].abort();[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000].open("GET", "ajax/domein.php?url=" + url + "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ext[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]", true);[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000].onreadystatechange=function() {[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]if (http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000].readyState == 4) {[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]document.getElementById(result[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]).innerHTML = http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000].responseText;[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]if (http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000].responseText == "vrij") {[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]document.getElementById(kopen[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]).innerHTML = echo(($user[uCoins] >= $res[prijs]) ? <input type="submit" name="nl" value="kopen"> : Niet genoeg punten);[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]} else {[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]document.getElementById(kopen[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]).innerHTML = ;[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]}[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]} else {[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]document.getElementById(result[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]).innerHTML = <img src="ajax/ajax-loader.gif">;[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]}[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]}[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]http[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000].send(null);[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$r[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$rows[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]}[/COLOR][COLOR= #007700];
}[/COLOR]

[COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++;[/COLOR]
[COLOR= #0000BB]$r[/COLOR][COLOR= #007700]++;
}[/COLOR]
?>
</script>
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
dat is niet echt een geweldig script wink
0
Andydewit

Lid · Topicstarter

Berichten
1.168
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@Sjoerd: Jou smaakyummie Geen fout gevonden?
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
toch wel beter dat je de functie checkdomain niet aanroept biggrinvan die code klopt niet veel. of je wilt iets anders dan logisch zal zijn
0
Andydewit

Lid · Topicstarter

Berichten
1.168
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hij doet het gewoon als ik hem gewoon neerzet hoor.
0
Andydewit

Lid · Topicstarter

Berichten
1.168
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Niemand?
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Om te beginnen gebruik je onnodig veel echos in de JS, haal die eerst weg!
Het word veel overzichtelijker als je ALLEEN de PHP variabelen echoot, en de rest gewoon doet
0
Andydewit

Lid · Topicstarter

Berichten
1.168
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@Eleky: dan werken de "fors" niet... Dus ik weet niet hoe het anders moet.
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