Jump to content

Mysql php


shage

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/74593-mysql-php/
Share on other sites

$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
}

Link to comment
https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-376961
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-377127
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/74593-mysql-php/#findComment-377347
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.