Jump to content

assigning an ID and showing results by a group?


colleyboy

Recommended Posts

Hi people.

 

I am creating a carpet website for a good friend of mine as a favour.  I am storing the carpets info in a MYSQL database and am currently trying to relay the info on a page.  I have the array kind of done but it is not producing the results I want.  Let me explain further:

 

The columns in my database under the table "carpets" are:

 

id (auto incremented)

colour

type

title

price

description

imageloc

 

------

 

under the type I have various types of carpet (6-ish).  They are: Twist, Striped etc etc...

 

Heres the php problem.

 

 

I have all the images there and ready on the page and want to link them all with linking commands. i.e:

 

the main page is at: http://www.ircdirect.co.uk/FTPServers/supremecarpets/index.php

 

the carpets results page is at: http://www.ircdirect.co.uk/FTPServers/supremecarpets/carpetlist.php

 

on the index.php page I want to link them so that for example:

 

If he looks for a striped carpet he clicks "striped" and is shows carpetlist.php but with the striped carpets displayed.

 

example link: <A HREF="carpetlist.php?type=striped">IMAGE HERE</A>

 

I have tried various coding on the carpetlist.php and cant seem to get it to work.

 

here is the snippets:

 

<?php
// Make a MySQL Connection
$query = "SELECT * FROM carpets GROUP BY type"; 

$result = mysql_query($query) or die(mysql_error());


while($row = mysql_fetch_array($result)){


echo "<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH=100% />";

echo "<TR />";

echo "<TD WIDTH=23 /><IMG SRC=images/main/search/topleft.png /></TD />";

echo "<TD BACKGROUND=images/main/search/top.png /> </TD />";

echo "<TD WIDTH=23 /><IMG SRC=images/main/search/topright.png /></TD />";

echo "</TR />";

echo "<TR />";

echo "<TD BACKGROUND=images/main/search/left.png />";
echo " ";
echo "</TD />";

echo "<TD BACKGROUND=images/main/search/bg.png />";

echo "<FONT FACE=VERDANA SIZE=1 />";
echo $row['title'];

echo "</TD />";

echo "<TD BACKGROUND=images/main/search/right.png />";

echo " ";

echo "</TD />";

echo "</TR />";

echo "<TR />";

echo "<TD WIDTH=23 /><IMG SRC=images/main/search/bottomleft.png /></TD />";

echo "<TD BACKGROUND=images/main/search/top.png /> </TD />";

echo "<TD WIDTH=23 /><IMG SRC=images/main/search/bottomright.png /></TD />";

echo "</TR />";

echo "</TABLE />";

echo "<BR />";

}
?>

 

It displays ALL the results which is not what I want.  I want only striped carpets, blue carpets etc....

 

Help is needed and VERY much appreciated!

 

Kind Regards,

Ian

Link to comment
Share on other sites

When you group them, it groups all within that category into one... what I think you want to do is:

 

$query = "SELECT * FROM carpets WHERE type = 'striped'"; 

 

so that it only pulls out the carpets where the type is striped.. or whatever the string or number for striped is :)

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.