OK here is my problem I have like 20 fields in sql so i wrote a foreach loop to list the contents of all my fields, no problem i need one column to be different so since this is an associative array i could go in and type in every field name using a while loop but i am thinking there has to be a different way if 19 of them need to be the same and only one needs to be different any ideas.
could you give an example? as far as i understand, you can fix it by placing the different fieldname outside the foreach loop.
Ok this will dumb your whole database table, or whatever you have specified in your query. while ($rows = mysql_fetch_field($result)) {echo '<th><a href="?'.$go.'sort='.$rows->name.'&order=ASC">UP</a>'.$rows->name.'<a href="?'.$go.'sort='.$rows->name.'&order=DESC">DOWN</a></th>';} echo "</tr>"; while ($carrot = mysql_fetch_assoc($result)) { echo "<tr>"; foreach($carrot as $list) { echo "<td>$list</td>"; } echo "</tr>"; } Code (markup): I need to hyper link one of the fields but not all of the fields.
just use $carrot['fieldname'] instead of the foreach, like this: while ($carrot = mysql_fetch_assoc($result)) { echo "<tr>"; echo "<td>" . $carrot['fieldname'] . "</td>"; echo "</tr>"; } PHP: if you only need 1 field from the database, you can modify your query so it will only return 1 field: SELECT fieldname FROM mytable Code (markup): will only return the values in the "fieldname" column
ah, yeah i knew i could to that but was trying to find a workaround since ONLY 1 of 20 fields has to be different, so i was looking for make all of them this way but this one not this way. all 20 fields will be columns in a table