0

Hi guys. I'm trying to validate some code, but getting ID already defined errors...which I 'm expecting as the code loops through a record set and re-uses the DIV id.

The question is how would you get round this? I thought about adding a simple variable +1 to the ID name as it loops, but it seems a bit of a fudge really...

Any suggestions? Thx in advance

<?
				while($row = mysql_fetch_array($result)){			
				
					if($row['depth']<1){
						echo "<h1>Buy ".$row['name']."</h1>";
						echo "<div id=\"buy_detail_sub\">";
						
						if(check_language_desc(stripslashes($row[$desc_lang]))){
							// we do have a description for this language...
							echo stripslashes($row[$desc_lang]);
						} else {
							//we don't have a description, so default to english
							echo stripslashes($row['description']);
						}
						
						echo "</div>";						

					} else {
						
						
						if($toggle){
							echo "<div id=\"buy_detail_sub_header_l\">
							 <a href=\"/buy/".$row['category_url']."/\">$row[0]</a>
							</div>";
							$toggle = 0;
						} else {
							echo "<div id=\"buy_detail_sub_header_r\">
							 <a href=\"/buy/".$row['category_url']."/\">$row[0]</a>
							</div>";
							$toggle = 1;
						}
					
					
					}
				}
		?>
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by SgtMash
0

Do you really need IDs? Usually if you are going to group some elements together for some reason, use the "class" attribute instead of IDs.

0

Yes, I think that would make the most logical sense.

As the class can control the style repetition, and get rid of the issues with the repeating Div entirely.

Thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.