shage Posted October 24, 2007 Share Posted October 24, 2007 I have a database that has products in them, such as wood floor and laminate flooring, i would like to be able to export all flooring to a text file from the database but have it come out like Laminate Flooring Name Name Name Wood Flooring Name Name Name The database is set up Name and Type, Name would be the product name and the type would either say wood or laminate. Right now it just makes a text file with everything bunched together, thank you for any advice Quote Link to comment https://forums.phpfreaks.com/topic/74593-mysql-php/ Share on other sites More sharing options...
almightyegg Posted October 24, 2007 Share Posted October 24, 2007 $select = mysql_query("SELECT * FROM table WHERE type='laminate'"); echo "Laminate Floors<br>"; while($laminate = mysql_fetch_array($select)){ // get info on preduct here //echo it out } $select = mysql_query("SELECT * FROM table WHERE type='wood'"); echo "Wood Floors<br>"; while($wood = mysql_fetch_array($select)){ // get info on preduct here //echo it out } Quote Link to comment https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-376961 Share on other sites More sharing options...
shage Posted October 24, 2007 Author Share Posted October 24, 2007 thank you thank you i was thinking that but didnt know if there was a easier way, again i thank you kindly Quote Link to comment https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-376962 Share on other sites More sharing options...
shage Posted October 24, 2007 Author Share Posted October 24, 2007 That would put the results into a text file like that? Quote Link to comment https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-376965 Share on other sites More sharing options...
almightyegg Posted October 24, 2007 Share Posted October 24, 2007 no. That gets the information to put into the file Quote Link to comment https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-376966 Share on other sites More sharing options...
shage Posted October 24, 2007 Author Share Posted October 24, 2007 Thank you gonna look into writting to the text file with each result Quote Link to comment https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-376977 Share on other sites More sharing options...
almightyegg Posted October 24, 2007 Share Posted October 24, 2007 Look into using fopen() www.php.net/fopen Quote Link to comment https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-376993 Share on other sites More sharing options...
shage Posted October 24, 2007 Author Share Posted October 24, 2007 still having trouble, hopefuly will figure it out Quote Link to comment https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-377125 Share on other sites More sharing options...
rajivgonsalves Posted October 24, 2007 Share Posted October 24, 2007 You could try the following code $select = mysql_query("SELECT distinct type FROM table"); while($arrSelect = mysql_fetch_array($select)){ // get info on preduct here //echo it out echo ucfirst(strtolower($arrSelect[0]))." Floors<br>"; $resSelect1 = mysql_query("SELECT * FROM table WHERE type='$arrSelect[0]'"); while($arrRow = mysql_fetch_array($resSelect1)){ // get info on preduct here //echo it out } } Cheer! Rajiv Quote Link to comment https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-377127 Share on other sites More sharing options...
shage Posted October 24, 2007 Author Share Posted October 24, 2007 i get it to echo out just trying to figure out how to group them with like Wood then one line be each product etc, its for a hard copy of the warehouse stock of what we have left etc, so would be easier to see that we have this for wood, this for laminate this for tile etc just trying to figure it out, all this should be put to a txt folder on the server Example Wood Cherry Walnut Carpet A B Tile A B Quote Link to comment https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-377347 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.