Tuesday, December 6, 2011

What am I doing wrong?

This is the page that should show all the images retrieved
from the dataset:



%26lt;!DOCTYPE html PUBLIC ''-//W3C//DTD XHTML 1.0
Transitional//EN'' ''
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''%26gt;

%26lt;html xmlns=''
http://www.w3.org/1999/xhtml''%26gt;

%26lt;head%26gt;

%26lt;meta http-equiv=''Content-Type'' content=''text/html;
charset=iso-8859-1'' /%26gt;

%26lt;title%26gt;Untitled Document%26lt;/title%26gt;

%26lt;style type=''text/css''%26gt;

%26lt;!--

#Layer1 {

position:absolute;

left:9px;

top:16px;

width:465px;

height:476px;

z-index:1;

}

--%26gt;

%26lt;/style%26gt;

%26lt;script type=''text/javascript''
xsrc=''includes/xpath.js''%26gt;%26lt;/script%26gt;

%26lt;script type=''text/javascript''
xsrc=''includes/SpryData.js''%26gt;%26lt;/script%26gt;

%26lt;script type=''text/javascript''%26gt;

var dsTest = new Spry.Data.XMLDataSet(''query.php'',
''container/element'');

%26lt;/script%26gt;



%26lt;/head%26gt;



%26lt;body%26gt;

%26lt;div id=''Layer1'' spry:region=''dsTest''%26gt;

%26lt;img spry:repeat=''dsTest'' src=''../public/{progetto}/{url}''
/%26gt;

%26lt;/div%26gt;

%26lt;/body%26gt;

%26lt;/html%26gt;





And here is query.php that creates the XML:





%26lt;?

require_once('../Connections/architetti.php');

$qstring = ''select * from gallerie'';

$result = mysql_query($qstring); //my own query function.
you can just use mysq_query

$xml = createXML_fromSQLResult($result);

header(''Content-type: text/xml'');

echo $xml;



function createXML_fromSQLResult(%26amp;$result,
$containerName=''container'', $elementName=''element'',
$encoding=''Shift_JIS'')

{

//this functions creates XML output from the SQL result.



$xml = %26lt;%26lt;%26lt;EOF

%26lt;?xml version=''1.0'' encoding=''{$encoding}'' ?%26gt;

%26lt;{$containerName}%26gt;

EOF;



while ($stuff = mysql_fetch_assoc($result)) {



$xml .= ''%26lt;{$elementName} id=\''{$stuff[id]}\''%26gt;'';

foreach($stuff as $key=%26gt;$value) {

$value = htmlspecialchars($value);

$xml .= %26lt;%26lt;%26lt;EOF

%26lt;{$key}%26gt;{$value}%26lt;/{$key}%26gt;\n

EOF;

}

$xml .= ''%26lt;/{$elementName}%26gt;\n'';

}



$xml .= %26lt;%26lt;%26lt;EOF

%26lt;/{$containerName}%26gt;

EOF;



return $xml;



}

?%26gt;







What am I doing wrong? Help, please I'm a real
newbie...What am I doing wrong?
Hello,



Could you tell us what are the results you actually get when
you run this code? I'm wondering if you have any JS errors or what
exactly is displayed into the browser.



One thing that I see wrong are into the HTML the xsrc
attributes for the script tags which should be src.



%26lt;script type=''text/javascript''
src=''includes/xpath.js''%26gt;%26lt;/script%26gt;

%26lt;script type=''text/javascript''
src=''includes/SpryData.js''%26gt;%26lt;/script%26gt;



Regards,

Cristian

No comments:

Post a Comment