SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    The data doesn't show up in the browser Need to fix and refactor php query help plea.

    i have the following database called “Sapateria” which contain two tables listed below and they have been set up as fallows.
    HTML Code:
    Table1 “shoe_kind”
    
      Kind_id       |      Shoe_name  
     --------------------------------------------------------------------
         1           |       K_swiss          
         1           |       Shmack          
         1           |       RBK              
    
    
    Table 2 “shoes”
    
      Kind_id       |  Shoe_name  |     Price    |    MoreInfo  
    --------------------------------------------------------------------
       1             |   K_swiss       |    11.00   |    More Info
       1             |   Shmack       |    25.32   |    More Info
       1             |   RBK            |    28.20    |    More Info
       1             |   Fubu           |    30.50    |    More Info
       1             |   Rockport     |    35.50    |    More Info
       1             |   Baby Phat    |   25.50     |    More Info
       1             |   Fubu          |   30.50     |    More Info
       2             |   Miralto        |   21.50    |    More Info
       2             |   Elario          |   21.40    |    More Info
       2             |   Unlisted       |   24.50    |    More Info
       2             |   Scans         |   28.50   |    More Info
       2             |   Stacy Adams|   31.50    |    More Info
       2             |   Barroni         |   28.50    |    More Info
       2             |   Anton Neroli  |   28.20    |    More Info
       2             |   Maximus        |   36.50    |    More Info
       3             |   Iron Boun      |   25.50     |    More Info
       3             |   Kingshow      |   30.50    |    More Info
       3             |   Vikings         |   34.50     |    More Info
       3             |   Dickies          |   31.50     |    More Info
       3             |   Everlast        |   31.50      |    More Info
       3             |   Lh. Farms      |   30.50     |    More Info
       3             |   Timberland     |  34.50      |    More Info
       3             |   Dr. Martens    |   31.50     |    More Info
    The Sql database is working ok but when I try to bring it in Dreamweaver through php codes then it doesn't appear in the browser firefox. I have set upt the code as follows:

    PHP Code:
    <table width="40%" border="0" cellspacing="0" cellpadding="0" bordercolor="#FF0033" bgcolor="#FFFFFF" id="shoesdetails">
    <
    td width="95"><table width="91%" height="217">
    <
    tr>
    <
    td bordercolor="#666666" bgcolor="#D83607" height="16" style="font-size:14px; font-weight:bold;"><div class="letras" align="center" style="background-image:url(../images/shoename.gif);"
    $query1 "SELECT shoes.shoes_nam,
    FROM shoes
    INNER 
    JOIN shoe_kind
    ON shoes.kind_id=shoe.kind_id"
    ;
     
    $shoename mysql_query($query,  $connection);
      if(!
    $result){
      die(
    "Database query failed: " mysql_error());
      } echo 
    $shoename;
    </
    div></td>
    </
    tr>
    <
    tr>
    <
    td height="100%" width="100%"   style="position:relative;"><img src="../images/airjordan.jpg" alt="sd" width="97%" height="80%"  border="1" style="border-color:#FF6600;" /></td>
    </
    tr>
    </
    table>
    <
    table height"100%" width="100%">
     <
    td width="45%" height="21" style="font-size:14px;"><img src="../images/price.gif" alt="aq" width="47%" height="21"  /></td>
     <
    td width="55%"><span class="txt_grey_b01">$</span><span class="txt_orange_b01">
    $query2 = &#8220;SELECT shoes.price,
    FROM shoes
    INNER 
    JOIN shoe_kind
    ON shoes
    .kind_id=shoe.kind_id&#8221;;
     
    $shoeprice mysql_query($query,  $connection);
      if(!
    $result){
      die(
    "Database query failed: " mysql_error());
      } echo 
    $shoeprice
    </
    span></td></table>
          <
    table height"100%" width="100%">
            <
    td width="57%" height="31" style="font-size:14px;">&nbsp;</td>
                <
    td width="43%" style="font-size:12px; margin-left:30px;"><p>
    $query3 = &#8220;SELECT shoes.moreinfo,
    FROM shoes
    INNER 
    JOIN shoe_kind
    ON shoes
    .kind_id=shoe.kind_id&#8221;;
     
    $shoeinfo mysql_query($query,  $connection);
      if(!
    $result){
      die(
    "Database query failed: " mysql_error());
      }
    echo 
    $shoeinfo;

    <
    p></td>
          </
    table></td>
    </
    table
    The code above consist of a table that has three <td> and the first one suppose to display the name of the shoes, the second the price and the third one More info about the shoes. I have done the query to echo it if there result. It looks like it result but it doesn't echo. Any suggestion?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Your SELECT query is wrong. It should select all the columns you need, you're only selecting the price column. Your column list also ends with a comma, the last column before the FROM should not have a comma after it.

  3. #3
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The right way to query it would be as fallows?

    PHP Code:
    $query1 "SELECT shoes.shoes_name, shoes.price, shoes.moreinfo
    FROM shoes
    INNER 
    JOIN shoe_kind
    ON shoes.kind_id=shoe.kind_id"


  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes, one query like that. Then you loop over the results:

    PHP Code:
    $query "SELECT shoes.shoes_name, shoes.price, shoes.moreinfo 
    FROM shoes 
    INNER 
    JOIN shoe_kind 
    ON shoes.kind_id=shoe.kind_id"


    $result mysql_query($query);

    while (
    $row mysql_fetch_array($result)) {
      echo 
    "<tr><td>" $row['shoes_name'] . "</td><td>" $row['price'] . "</td><td>" $row['moreinfo'] . "</td></tr>";


  5. #5
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to echo the value of the shoename I have formulate the following php code

    PHP Code:
    $shoesname mysql_query($query1$connection);
      if(!
    $shoesname){
      die(
    "Database query failed: " mysql_error());
      } 
      
    $result mysql_fetch_array($shoesname);
      
    $shoesname $result['shoe_name'];
    echo 
    $shoesname
    it does echo the value but I want to echo the value just if the shoe_kind.kind_id == shoe.kind_id How can I formulate that if then statement.

    I want to echo the value 'shoe_name' if the person select or click on the shoe_kind.shoe_name which I have put in a sidebar on the left of the website through an <ul> tag.

    Can someone help me to formulate that if then statement.

  6. #6
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok I will try the looping.

  7. #7
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried the coding below but it didn't work because I don't know if I need more php tags , the td tags coding changes color when I move the ?> ending tag after the end of the </td> tag. do you have any suggestions?

    PHP Code:
    <table width="40%" border="0" cellspacing="0" cellpadding="0" bordercolor="#FF0033" bgcolor="#FFFFFF" id="shoesdetails">
    <
    td width="95"><table width="91%" height="217">
    $query1 "SELECT shoes.shoes_name, shoes.price, shoes.moreinfo
    FROM shoes
    INNER 
    JOIN shoe_kind
    ON shoes.kind_id=shoe.kind_id"
    ;
     
    $result mysql_query($query,);
      if(!
    $result){
      die(
    "Database query failed: " mysql_error());


     while (
    $row mysql_fetch_array($result)) {
    echo
    "<tr>
    <td bordercolor="
    #666666" bgcolor="#D83607" height="16" style="font-size:14px; font-weight:bold;"><div class="letras" align="center" style="background-image:url(../images/shoename.gif);"> 
    </div>" . $row['shoes_name'] . "</td>
    </
    tr>"
    <tr>
    <td height="
    100%" width="100%"   style="position:relative;"><img src="../images/airjordan.jpg" alt="sd" width="97%" height="80%"  border="1" style="border-color:#FF6600;" /></td>
    </tr>
    </
    table>
    <
    table height"100%" width="100%">
     <
    td width="45%" height="21" style="font-size:14px;"><img src="../images/price.gif" alt="aq" width="47%" height="21"  /></td>
     <
    td width="55%"><span class="txt_grey_b01">$</span><span class="txt_orange_b01">
    " . $row['price'] . "
    </span></td></table>
          <
    table height"100%" width="100%">
            <
    td width="57%" height="31" style="font-size:14px;">&nbsp;</td>
                <
    td width="43%" style="font-size:12px; margin-left:30px;"><p>
    " . $row['moreinfo'] . "

    <p></td>
          </
    table></td
    }
    </
    table

  8. #8
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was thinking if I was going to need to scape all inside the <table><tr><td></td></tr></table> since everything was changing calors....

    When I am talk about scaping I mean this "\"\

  9. #9
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I think you need to start with the PHP Tutorial: Your First PHP Page, PHP Tutorial: Something Useful. You need a better understanding of going in and out of PHP mode.

  10. #10
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok,

    Yes i didn't have any idea how to go out php mode in table.

    Thank you I will read the tutorials


Bookmarks

Posting Permissions

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