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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.