SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Threaded View

  1. #1
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    0 Post(s)
    0 Thread(s)

    Need help for a query that makes a table to depend of another table to execute.

    The first query is put in an Ul at the left side of the web page that contain three kind of shoes,
    HTML Code:
    Dress shoes
    Then the second query presents a table of the sneakers, dress shoes or Boots, or whatever kind you click on the <ul>, in other words the content of the second query will depend on the kind of shoe you choose or click on from the <ul> at the left side of the page similar to the illustration above. Now what I am trying to accomplish is to JOIN the two queries, where whenever a user click on a kind of shoe on the <ul> then it presents all the kinds of that kind in the table which is going to be at the right side of the page containing the second query.

    What I have done so far is to create a database with two table one named Shoe_kind and the other Shoe. in both tables I have created a field called kind_id so it can connect together. The first kind of shoe has 8 shoes and all and each shoe has the integer of (1) assigned to its kind_id field, then the second kind of shoe has 8 shoes as well and each shoe has the integer of (2) assigned to its kind_id field, and so on.... but so far I haven't get them connected, what am I missing? so that when a user click on a kind of shoes all the shoes kinds of that specific kind appears according to the relationship they have through the kind_id field.

    The question is How can I improve the coding to reach that command?

    Help please.

    PHP Code:
    $sel_shoe $_GET['shoe'];
    }else { 
    $sel_shoe "";


    <td style="left:2px;" bordercolor="#666666" bgcolor="#ffffff" border="1" width="156"><ul class="shoe"><?php 
    "SELECT * 
                  FROM shoe_kind
                  ORDER BY position ASC"
    $result mysql_query($query$connection);
    "Database query failed: " mysql_error());
    $row mysql_fetch_array($result)){
      if (
    $row["kind_id"] == $sel_shoe) {
    " class=\"selected\"";
    "><a href=\"example1.php?shoe=" urlencode($row["kind_id"]) ."\">{$row["shoename"]}</a></li>";
    ?></ul> </td>

     <?php $query "SELECT shoe.shoename, shoe.price, shoe.moreinfo 
    FROM shoe
    JOIN shoe_kind 
    ON shoe.kind_id=shoe_kind.kind_id"

    $result mysql_query($query$connection);
    while (
    $row mysql_fetch_array($result)) {
    "<table style=\"float:left\">
    <td width=\"150\" style=\"text-align:center;\">" 
    $row['shoename'] . "</td>
    <td height=\"100\" width=\"100\"   style=\"position:relative;\">
    <img src=\"../images/shoesname.jpg\" alt=\"sd\" width=\"97\" height=\"80\"  border=\"1\" style=\"border-color:#FF6600;\" />
    <td width=\"5\" height=\"21\" ></td><td>" 
    $row['price'] . "</td>
    $row['moreinfo'] . "</td>

    Last edited by co.ador; May 10, 2009 at 20:47.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts