Jump to content

Arrays and variables on mouseclick


RobDgital

Recommended Posts

Hi

I have a page that the user selects a category and I have the page sending a variable to a page.

However, I want the user to be able to select multiple options and therefore need the page doing the query to build an array and change the search results accordingly!

Please can someonehelp me with what I have as I am jsut NOT getting my head around this!

 

Here is the 'form' info

 

<input name="jqdemo" value="6" type="checkbox" id="party"/>
<label for="party"></label>
<a class="checkbox-select" href="# id="6" onclick="showUser(this.id)""><img src="Assets/images/blank.png" alt="" width="120" height="180" /></a>
<a class="checkbox-deselect" href="#" id="0" onclick="showUser(this.id)"><img src="Assets/images/blank.png" alt="" width="120" height="180" /></a>

 

Then this is the page that is doing the query

<?php
$q=$_GET["q"];

$con = mysql_connect('localhost', 'root', '');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("db_pyf", $con);

//$sql="SELECT * FROM tbl_product WHERE cat_id IN '".$q."'";
$sql="SELECT * FROM tbl_product WHERE cat_id IN (3,1,2)";

$result = mysql_query($sql);

echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
<th>Hometown</th>
<th>Job</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['prod_name'] . "</td>";
  echo "<td>" . $row['prod_desc1'] . "</td>";
  echo "<td>" . $row['member_id'] . "</td>";
  echo "<td>" . $row['cat_id'] . "</td>";
  echo "<td>" . $row['cat_id'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?> 

 

But, as I have said, I want the user to be able to select multiple options and want the search to adjust accordingly!

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.