我真的不喜欢我的PHP经验,但我认为这是一个学习曲线。有人可以查看我的代码并让我知道为什么我的某些类没有显示我的html标签吗?
$g_books = array();
$g_elem = null;
function startElement( $parser, $name, $attrs )
{
global $g_books, $g_elem;
if ( $name == 'AFFILIATEXML' )
{
$g_books []= array();
}
$g_elem = $name;
}
function endElement( $parser, $name )
{
global $g_elem;
$g_elem = null;
}
function textData( $parser, $text )
{
global $g_books, $g_elem;
if ( $g_elem == 'PRODUCTID' ||
$g_elem == 'PRODUCTNAME' ||
$g_elem == 'PRODUCTPRICE' ||
$g_elem == 'CLASS_DATE'||
$g_elem == 'LONGDESCRIPTION')
{
$g_books[ count( $g_books ) - 1 ][ $g_elem ] = $text;
}
}
$parser = xml_parser_create();
xml_set_element_handler( $parser, "startElement", "endElement" );
xml_set_character_data_handler( $parser, "textData" );
$f = fopen( 'http://webinars.knowledgewave.com/xml/1033499.xml', 'r' );
while( $data = fread( $f, 4096 ) )
{
xml_parse( $parser, $data );
}
xml_parser_free( $parser );
//start table code
foreach( $g_books as $book )
{
if ($book['CLASS_DATE'] == 'ON DEMAND')
{
$bb = $book['LONGDESCRIPTION'];
$b = html_entity_decode($bb);
echo "<tr><td>";
echo "<table border=0>";
echo"<tr><td><a id='".$book['PRODUCTID']."link' href='javascript:showDetails(".$book['PRODUCTID'].")'>".$book['PRODUCTNAME']."</a></td></tr>";
echo "<tr><td id='".$book['PRODUCTID']."' style='font-size: 18px; height: 20px; display: block;'>".$bb."dd</td></tr>";
echo "</table></td>";
echo"<td>N/A</td>";
echo"<td><a href='http://members.logontolearn.com/amember/signup.php'>WATCH NOW</a></td>";
echo"</tr>";
}
}
//end table code;
答案 0 :(得分:0)
echo "<tr><td>";
echo "<table border=0>";
echo "<tr><td><a id=\"$book[PRODUCTID].link\" href='javascript:showDetails(\"$book[PRODUCTID]\")'>$book[PRODUCTNAME]</a></td></tr>";
echo "<tr><td id=\"$book[PRODUCTID]\" style=\"font-size: 18px; height: 20px; display: block;\">".$bb."dd</td></tr>";
echo "</table></td>";
echo "<td>N/A</td>";
echo "<td><a href=\"http://members.logontolearn.com/amember/signup.php\">WATCH NOW</a></td>";
echo "</tr>";
试试
答案 1 :(得分:0)
由于这实际上是按预期输出标签,我只能猜测问题出现在您网站的整体HTML中 - 如果您可以提供URL,我们可能会弄清楚它为什么没有显示。如果没有,我建议您通过validator.w3.org之类的方式运行HTML输出。此外,PHP4已经被正式弃用了一段时间 - 尝试查看GoPHP5的提供商列表。