helloise Posted April 26, 2011 Share Posted April 26, 2011 i have a php script: $sql5 = "select *,count(*) from rc_language_type_assoc_table group by language_type_id"; $result5 = mysql_query($sql5); //not correct $count5 = mysql_num_rows($result5); //not correct $myFile = "/home/rainbowcode/StatsFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $sql5."\n"); the above is not what i want, i want the actual result set of the select to print in my StatsFile how can i achieve this please??? Quote Link to comment https://forums.phpfreaks.com/topic/234737-how-to-output-results-of-a-select-to-text-file/ Share on other sites More sharing options...
silkfire Posted April 26, 2011 Share Posted April 26, 2011 Remember that what you get from a MySQL select query is a MySQL resource that only PHP can interact with. Loop through the result set and add everything into a variable and separate your values somehow. Then save that variable to the file. Quote Link to comment https://forums.phpfreaks.com/topic/234737-how-to-output-results-of-a-select-to-text-file/#findComment-1206302 Share on other sites More sharing options...
helloise Posted April 26, 2011 Author Share Posted April 26, 2011 please can you help me with this? i have no idea on how to do this? i am new to php thanks Quote Link to comment https://forums.phpfreaks.com/topic/234737-how-to-output-results-of-a-select-to-text-file/#findComment-1206303 Share on other sites More sharing options...
silkfire Posted April 26, 2011 Share Posted April 26, 2011 I need to know the database structure or at least what it is you're getting in return from the query. Quote Link to comment https://forums.phpfreaks.com/topic/234737-how-to-output-results-of-a-select-to-text-file/#findComment-1206304 Share on other sites More sharing options...
helloise Posted April 26, 2011 Author Share Posted April 26, 2011 thank you very much but i have the answer Quote Link to comment https://forums.phpfreaks.com/topic/234737-how-to-output-results-of-a-select-to-text-file/#findComment-1206309 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.