Nieuw lid |
|
Hallo allemaal,
Ik ben met een nieuwsscriptje bezig. De volgende code wil ik als voorbeeld gebruiken, alleen er komt niks op het scherm. Verder heb ik 2 velden aangemaakt. 1 Tekstveld met als instance name Title_txt0 en 1 tekstveld met als instance name Comments_txt0.
//Create the URLLOader instance
var myLoader:URLLoader = new URLLoader();
//the data will come as URL-encoded variables
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
//Load using an URLRequest, even beeing local
myLoader.load(new URLRequest("http://localhost/jarahdamiel.com/anastasio.php"));
//onLoad handler listener
myLoader.addEventListener(Event.COMPLETE, onDataLoad);
//add a listener for the complete event
function onDataLoad(evt:Event){
for(var i:uint=0; i<evt.target.data.cant; i++){
this["Title_txt"+i].htmlText = "<b>"+evt.target.data["Title"+i]+"</b>";
this["Comments_txt"+i].text = evt.target.data["Comments"+i];
var loader:Loader = new Loader();
this["holder_mc"+i].addChild(loader);
loader.load(new URLRequest(evt.target.data["Image"+i]));
}
}
//Create the URLLOader instance var myLoader:URLLoader = new URLLoader(); //the data will come as URL-encoded variables myLoader.dataFormat = URLLoaderDataFormat.VARIABLES; //Load using an URLRequest, even beeing local myLoader.load(new URLRequest("http://localhost/jarahdamiel.com/anastasio.php")); //onLoad handler listener myLoader.addEventListener(Event.COMPLETE, onDataLoad); //add a listener for the complete event function onDataLoad(evt:Event){ for(var i:uint=0; i<evt.target.data.cant; i++){ this["Title_txt"+i].htmlText = "<b>"+evt.target.data["Title"+i]+"</b>"; this["Comments_txt"+i].text = evt.target.data["Comments"+i]; var loader:Loader = new Loader(); this["holder_mc"+i].addChild(loader); loader.load(new URLRequest(evt.target.data["Image"+i])); } }
PHP:
<?php
$connect = mysql_connect("localhost", "root", "");
mysql_select_db("test", $connect);
$result = mysql_query("SELECT Title, Comments, Image FROM titles");
$cant = 0;
while($row=mysql_fetch_array($result)){
echo "Title$cant=$row[Title]&Comments$cant=$row[Comments]&Image$cant=$row[Image]&";
$cant++;
}
echo "cant=$cant";
?>
<?php $result = mysql_query("SELECT Title, Comments, Image FROM titles"); $cant = 0; echo "Title$cant=$row[Title]&Comments$cant=$row[Comments]&Image$cant=$row[Image]&"; $cant++; } ?>
|