I want to select some records from a table and display them(let’s illustrate with this example) -:
$sql=mysql_query("select headline,body from theTable where id='$id' order by id DESC");
The code above makes ALL the headlines to be bold,but what i want is to make ONLY the first displayed headline to be bold - not all the results.The question is - is there a way to selectively format a particular row from a result set, how do i twist the code above to allow for this?
What seems to be a solution, is to use 2 SELECT queries - one for the row of interest, and the other for the other rows, apart from being inefficient, there’s an obvious flaw with
now you can replace $highlighted = array(1); with $highlighted = array(3,7,9); to emphasise those ones. With a slight variation you could also turn this into highlighting every 5th/10th/etc. headline - I don’t have the time to write code for this though, let me know if you need this one and I’ll have a look later.
then what about my other suggestion? cranial-bore’s solution is good if you only want to catch the first headline, my suggestion of using a dummy variable and increase it through the loop would enable you to address any row you want.
why not use an if statement in there? in simple terms an if id = xx then echo strong end if, … and another if for /strong, or a combined if/else. Or create a dummy variable and count it up in the while loop and use that in your if statement instead of the id.
Loved to hear opinions on this and alternative suggestions.
Yeah, IE tends to show weird ‘Navigation cancelled’ error dialogs when it encounters self-closed tags that it isn’t expecting. In all fairness, as you said, it’s not really IE’s fault. It just sucks that IE doesn’t do application/xml+xhtml, pretty much causing the failure of proper XHTML and imploding the space-time continuum.