Fruct0se Posted September 9, 2009 Share Posted September 9, 2009 This always works fine except for some reason when using the LIKE statement. I am trying to return a group of rows and call them out by their column names. So if I have a column called NAME then when extracting the row I normally can reference that result by echoing $NAME, when using the like statement it is returning 0 and 1 etc... for the column names, any ideas? <?php $result = mysql_query("Select * from images where NAME like '$search%'"); while($i = mysql_fetch_row($result)){ //This for each will echo: 0 NAMEofIMAGE foreach ($i as $name=>$val) { echo "$name is a $val <BR/>"; } //This will echo nothing for the $NAME because the query is not returning the column names extract($i); echo "<b>Name: ".$NAME."</b><br/>"; } ?> Like I said, without the LIKE statement the column names are returned and when extracted can be used. Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/173679-solved-returning-column-name-as-variable/ Share on other sites More sharing options...
Fruct0se Posted September 9, 2009 Author Share Posted September 9, 2009 Ok I figured it out...not enough caffeine in my system today. I was using mysql_fetch_row when I should have been using mysql_fetch_assoc Link to comment https://forums.phpfreaks.com/topic/173679-solved-returning-column-name-as-variable/#findComment-915579 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.