Jump to content

Recommended Posts

Hi Everybody!

 

My name is David, I have been using PHP for a long time but only recently I got serious with it and started working on bigger projects, involving the use of big SQL databases.

 

Right now I'm involved in a charitable project, www.vsc.org.uk , but I'm having a problem.

 

On the homepage, all the affiliated retailers are usually shown.  To achieve that I used this code, to take them from our cp (corporate partners) table and display them on the page:

======================================================================

 

<?php

$self = $_SERVER['PHP_SELF'];

{

 

$ctg = @$_GET['c'] ;

list($cata, $catb, $catc, $catd, $cate) = explode(" ", $ctg);

$query = mysql_query("SELECT * FROM cp ORDER by cp");

while ($row = mysql_fetch_array($query))

 

======================================================================

 

Now, I'd like to create a series of category links on top of the page that, when clicked, look through the cat and subcat columns in my table and show only the suitable affiliate businesses.

 

=======================================================================

 

<?php

$rs = @$_GET['r'] ;

list($var1, $var2, $var3, $var4, $var5) = explode(" ", $rs);

$query = mysql_query("SELECT * FROM cp WHERE cat LIKE '%$var1%' ");

?>

 

 

<a href='http://www.vsc.org.uk/index.php?r=Books Magazines'> Books and Magazines</a>

<a href='http://www.vsc.org.uk/index.php'> Food and Wine</a>

<a href='http://www.vsc.org.uk/index.php'> Business and Finance</a>

<a href='http://www.vsc.org.uk/index.php'> Fashion</a>

<a href='http://www.vsc.org.uk/index.php'> Holidays</a>

<a href='http://www.vsc.org.uk/index.php'> Home and Garden</a>

<a href='http://www.vsc.org.uk/index.php'> Entertainment</a>

<a href='http://www.vsc.org.uk/index.php'> Computer and Technology</a>

<a href='http://www.vsc.org.uk/index.php'> Electrical</a>

<a href='http://www.vsc.org.uk/index.php'> Music</a>

 

======================================================================

 

 

For example, after clicking on the links "Books and Magazines" the homepage, instead of showing everything from 123-Reg to WHSmith would show only Waterstones, Pickabook and the other retailers that in the cat or subcat columns are describes as "Books" or "Magazines".

 

When I tested the above code, clicking on the Books and Magazines link, the page was still returning the list of all the affiliate businesses.

 

Any help is much appreciated, thank you!

 

D

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.