如何在HTML属性旁边嵌入PHP

Here's a simple $64,000.00 question for everyone.

UPDATE: this is a PHP page... not a .html page...

I have a tag on an HTML page, basically I have something like this:

<td id="data">

... some other stuff

</td>

What I NEED to do is capture the PHP variable for the "ID" coming from the database and place it NEXT TO the "data" value in the ID attribute like this:.

<td id="data<?php echo $row_listNoticeboard['id']; ?>">

... some other stuff

</td>

But Netbeans 7.4 gives me an error stating:


Bad value "data" for attribute "id" on element "div": An ID must not contain whitespace. Syntax of id: An ID consists of at least one character but must not contain any whitespace.

From line 76, column 29; to line 76, column 152

(Rule Category: Attributes)

So in Classic ASP I'd simply do it like this and have been over the years:

<td id="data<% response.write('id') %>">

.... some other stuff

</td>

Thanks

Its a netbeans bug.

NetBeans HTML validator doesn't support embedded PHP code, so it is trying to validate your PHP code as a part of the HTML- which is of-course not.

Just disable the HTML error checking - you'll find it by clicking on the error bulb on left and this will fix it.