Hello Karl, Because the code is never to be reused, I have put it all-in-one. But I agree on creating separate functions. Before I go into that I would like to solve my datagrid issue first.
I thought using it is common to use double quotes when handling strings and single quotes when code needs to be parsed? Are there side effects to be expected when using only single quotes? >From php.net is where I have got this so far. Also http://www.w3schools.com is very helpful. Thanks very much for all your help!!! Best regards, Cor -----Original Message----- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: woensdag 8 augustus 2012 11:12 To: Flash Coders List Subject: Re: [Flashcoders] HTML in Datagrid component Hey Cor, One thing I noticed was the string $xmlOutput was switching between single and double quotes. Probably want to stick to one or the other. Excuse the re-write, but this is how I would write that php. Don't know if it works as I can not test, but try this code and let me know what you get. Also, you may want to separate each call to the database into separate functions. IE: function getProjects() { } function getUserData() { } function getMaterials() { } $projects = getProjects(); $userdata = getUserData(); $materials = getMaterials(); etc.. then have a function that puts together the XML results. function createXML($projects, $userdata, $materials) { } Your call on that though. If the code I gave does not work, try taking a look here to see if you can find a solution for the special characters. http://php.net/manual/en/function.htmlspecialchars.php php.net is gold! Best of luck! :) Hope everybody doesn't mind the php convo being a flash list. If so message me personally Cor. //CODE -------------------------- <?php ///////////// Read Project ///////////// if (isset($_POST['sendRequest']) && $_POST['sendRequest'] == "read_project") { $xmlOutput = ""; $project_nummer = ""; $project_klantnummer = ""; $currentTable = "tbl_projecten"; if ($_POST['isParticulier'] == "ja") { $currentTable = "tbl_particulier_projecten"; } $project_nummer = $_POST['project_nummer']; $xmlOutput = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; $xmlOutput .= "\n<data>"; //-------PROJECTGEGEVENS $sql = "SELECT * FROM ".mysql_real_escape_string($currentTable)." WHERE project_nummer =".htmlentities(mysql_real_escape_string($project_nummer)); $result = mysql_query($sql); $recordArray = array(); //maak assoc array om fieldnames als XML-tags te gebruiken while ($row = mysql_fetch_assoc($result)) { array_push($recordArray, $row); } for ($i=0; $i<count($recordArray); $i++) { //echo $recordArray[$i]['id']; $xmlOutput .= "\t<project>\n"; // $key is de assoc fieldname en $value de inhoud foreach ($recordArray[$i] as $key => $value) { $xmlOutput .= "\t\t<" . $key . ">" . htmlspecialchars(stripslashes($value), ENT_QUOTES, "UTF-8") . "</" . $key . ">\n"; if($key == "project_klantnummer"){ $project_klantnummer = $value; }//end if }//end foreach $xmlOutput .= "\t</project>\n"; } //------- KLANTGEGEVENS $sql = "SELECT * FROM tbl_klanten WHERE klant_nummer=".mysql_real_escape_string($project_klantnummer); $result = mysql_query($sql); $recordArray = array(); //maak assoc array om fieldnames als XML-tags te gebruiken while ($row = mysql_fetch_assoc($result)) { array_push($recordArray, $row); } for ($i=0; $i<count($recordArray); $i++) { //echo $recordArray[$i]['id']; $xmlOutput .= "\t<klant>\n"; // $key is de assoc fieldname en $value de inhoud foreach ($recordArray[$i] as $key => $value) { $xmlOutput .= "\t\t<" . $key . ">" . htmlspecialchars(stripslashes($value), ENT_QUOTES, "UTF-8") . "</" . $key . ">\n"; } $xmlOutput .= "\t</klant>\n"; } //------- MATERIALENVERBRUIK $currentTable = "tbl_materialen_verbruik"; if ($_POST['isParticulier'] == "ja") { $currentTable = "tbl_particulier_materialen_verbruik"; } $sql = "SELECT * FROM ".mysql_real_escape_string($currentTable)." WHERE mv_projectnummer =".htmlentities(mysql_real_escape_string($project_nummer)); $result = mysql_query($sql); $recordArray = array(); //maak assoc array om fieldnames als XML-tags te gebruiken while ($row = mysql_fetch_assoc($result)) { array_push($recordArray, $row); } $xmlOutput.="<materialen_verbruik>"; for ($i=0; $i<count($recordArray); $i++) { //echo $recordArray[$i]['id']; $xmlOutput .= "\t<mv>\n"; // $key is de assoc fieldname en $value de inhoud foreach ($recordArray[$i] as $key => $value) { $xmlOutput .= "\t\t<" . $key . ">" . htmlspecialchars(stripslashes($value), ENT_QUOTES, "UTF-8") . "</" . $key . ">\n"; } $xmlOutput .= "\t</mv>\n"; } $xmlOutput.="</materialen_verbruik>"; //------- URENVERBRUIK $currentTable = "tbl_uren_verbruik"; if ($_POST['isParticulier'] == "ja") { $currentTable = "tbl_particulier_uren_verbruik"; } $sql = "SELECT * FROM ".mysql_real_escape_string($currentTable)." WHERE uv_projectnummer =".htmlentities(mysql_real_escape_string($project_nummer)); $result = mysql_query($sql); $recordArray = array(); //maak assoc array om fieldnames als XML-tags te gebruiken while ($row = mysql_fetch_assoc($result)) { array_push($recordArray, $row); } $xmlOutput.="<uren_verbruik>"; for ($i=0; $i<count($recordArray); $i++) { //echo $recordArray[$i]['id']; $xmlOutput .= "\t<uv>\n"; // $key is de assoc fieldname en $value de inhoud foreach ($recordArray[$i] as $key => $value) { $xmlOutput .= "\t\t<" . $key . ">" . htmlspecialchars(stripslashes($value), ENT_QUOTES, "UTF-8") . "</" . $key . ">\n"; } $xmlOutput .= "\t</uv>\n"; } $xmlOutput.="</uren_verbruik>"; //------- MATERIALEN $sql = "SELECT * FROM tbl_materialen"; $result = mysql_query($sql); $recordArray = array(); //maak assoc array om fieldnames als XML-tags te gebruiken while ($row = mysql_fetch_assoc($result)) { array_push($recordArray, $row); } $xmlOutput.="<materialen>"; for ($i=0; $i<count($recordArray); $i++) { //echo $recordArray[$i]['id']; $xmlOutput .= "\t<mat>\n"; // $key is de assoc fieldname en $value de inhoud foreach ($recordArray[$i] as $key => $value) { $xmlOutput .= "\t\t<" . $key . ">" . htmlspecialchars(stripslashes($value), ENT_QUOTES, "UTF-8") . "</" . $key . ">\n"; } $xmlOutput .= "\t</mat>\n"; } $xmlOutput.="</materialen>"; //------- USERDATA ZONDER ACCOUNT_TYPE EN WACHTWOORD ! $sql = "SELECT user_id, voorletters, tussenvoegsel, achternaam, uurloon FROM tbl_users"; $result = mysql_query($sql); $recordArray = array(); //maak assoc array om fieldnames als XML-tags te gebruiken while ($row = mysql_fetch_assoc ($result)) { array_push($recordArray, $row); } $xmlOutput.="<users>"; for ($i=0; $i<count($recordArray); $i++) { //echo $recordArray[$i]['id']; $xmlOutput .= "\t<user>\n"; // $key is de assoc fieldname en $value de inhoud foreach ($recordArray[$i] as $key => $value) { $xmlOutput .= "\t\t<" . $key . ">" . htmlspecialchars(stripslashes($value), ENT_QUOTES, "UTF-8") . "</" . $key . ">\n"; } $xmlOutput .= "\t</user>\n"; } $xmlOutput.="</users>"; //sluit de root tag $xmlOutput .= "</data>"; header("Content-type: text/xml"); print "returnXML=".$xmlOutput; } //End READ PROJECT ?> //END CODE ------------------ FYI, the ENT_QUOTES and "UTF-8" can be removed if you wish. That is mostly what I wanted to see if works. Best, Karl On Aug 8, 2012, at 2:19 AM, Cor wrote: > Karl, > > Maybe the full picture helps some more > I use these functions to create a xml string to return to Flash. > With use of the mysql fieldnames as key en the content as value and > never > have to worry about wath the fieldnames are. > So when Flash reads a project it send a URLVariable to PHP: > Karl DeSaulniers Design Drumm http://designdrumm.com _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ----- No virus found in this message. Checked by AVG - www.avg.com Version: 2012.0.2197 / Virus Database: 2437/5185 - Release Date: 08/07/12 _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders