Darkmatter5 Posted October 28, 2008 Share Posted October 28, 2008 Here's my table data Folders fol_name cabinet_id Stocks 4 Telephone 2 Water and Electric 2 Credit Card statement 2 Here's the query and code: <?php $query="SELECT fol_name FROM folders WHERE cabinet_id=2 ORDER BY fol_name ASC"; $result=mysql_query($query) or die($query. '<br >' .mysql_error()); $row=mysql_fetch_array($result); while($row=mysql_fetch_array($result)) { echo "$row[fol_name]<br>"; } ?> Now if I run the query in PHPMyAdmin it'll give me this: fol_name Credit Card statement Telephone Water and Electric If the code is from on my site it outputs this: Telephone Water and Electric Where's Credit Card statement?? Link to comment https://forums.phpfreaks.com/topic/130448-help-with-unknown-query-output/ Share on other sites More sharing options...
prexep Posted October 28, 2008 Share Posted October 28, 2008 Try something like this. <?php $query="SELECT * FROM folders WHERE cabinet_id=2 ORDER BY fol_name ASC"; $result=mysql_query($query) or die($query. '<br >' .mysql_error()); $row=mysql_fetch_array($result); while($row=mysql_fetch_array($result)) { echo "$row[fol_name]<br>"; echo "$row[stocks]<br>"; echo "$row[Telephone]<br>"; echo "$row[Credit Card statement]<br>"; echo "$row[Water and Electric]<br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/130448-help-with-unknown-query-output/#findComment-676724 Share on other sites More sharing options...
revraz Posted October 28, 2008 Share Posted October 28, 2008 Why would he want to do that, he wants the DATA in the column. Everything looks fine. Are you sure the cabinet_id is in fact 2 for Credit Card? Link to comment https://forums.phpfreaks.com/topic/130448-help-with-unknown-query-output/#findComment-676809 Share on other sites More sharing options...
Darkmatter5 Posted October 28, 2008 Author Share Posted October 28, 2008 Yep it's 2 for Credit Card Statements. I don't get it, I've never had HP do this before? What is the command to output everything in an array? Maybe if I output all of $row's contents I'll see if Credit Card Statements is in it or not. Link to comment https://forums.phpfreaks.com/topic/130448-help-with-unknown-query-output/#findComment-676847 Share on other sites More sharing options...
bobbinsbro Posted October 28, 2008 Share Posted October 28, 2008 print_r($array) or var_dump($array) Link to comment https://forums.phpfreaks.com/topic/130448-help-with-unknown-query-output/#findComment-676850 Share on other sites More sharing options...
Barand Posted October 28, 2008 Share Posted October 28, 2008 $result=mysql_query($query) or die($query. '<br >' .mysql_error()); $row=mysql_fetch_array($result); // <<< read row and throw it away while($row=mysql_fetch_array($result)) { Link to comment https://forums.phpfreaks.com/topic/130448-help-with-unknown-query-output/#findComment-676862 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.