Question About Layout

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashraf02
    New Member
    • Feb 2008
    • 53

    Question About Layout

    For my online store i would like about three items to be displayed in one row however because of the php code i wouldn't know how to display it like this. currently the items are displayed one after the other only 1 item per row which makes the page look a bit crap. can anyone please help. i will post the code below.

    thanks in advanced.


    [PHP] if (mysql_num_rows ($get_suit_res) > 0 ) {
    $display_block = "<p><em>Sor ry no items in this Smart</em></p>";

    while ($Suits = mysql_fetch_arr ay($get_suit_re s)) {
    $Suit_id = $Suits[Suit_ID];
    $Suit_title = stripslashes($S uits[Suit_Brand]);
    $Suit_price = $Suits[Suit_Price];
    $Suit_Image = $Suits[Suit_Image];

    $display_block .= "
    <table align=\"center\ ">
    <tr>
    <td>
    <a href=\"showitem .php?Suit_ID=$S uit_id\">$Suit_ title</a>
    <h2>£$Suit_pric e</h2>
    <img src=\"$Suit_Ima ge\" width=\"100\" height=\"200\"> </img>
    </td>
    </tr>
    </table>";
    }

    $display_block .= "<ul>";
    }

    }
    }
    }[/PHP]
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    What about instead of having them all in one row and one column, have it in one row and three columns? That's how I would do it if I was using tables already.

    Comment

    • ashraf02
      New Member
      • Feb 2008
      • 53

      #3
      thanks for the quick reply servant but i've tried it and still looks shit. basically i want three items on one row. what if i use div instead of tables do u think that'll sort it and if i do can u giv me a brief indication of how to go about it.

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        I have changed you markup, the use of variables in strings was done wrong and badly, have a look at the changes and how I use "." between strings and variables:

        [PHP]<?php
        echo( "<table align=\"center\ ">
        <tr>
        <td><a href=\"showitem .php?Suit_ID=". $Suit_id."\">". $Suit_title."</a></td>
        <td><h2>£".$Sui t_price."</h2></td>
        <td><img src=\"".$Suit_I mage."\" width=\"100px\" height=\"200px\ "></img></td>
        </tr>
        </table>
        ?>[/PHP]

        You can use divs, and even though this is no longer a php question, I can help you with it. However I must be going to bed, so I will have a try tomorrow, but by then a moderator is likely to have moved this to the html/CSS forum where you can get better help than I can offer with regards to layout. Just have a go with what I have up top and tell me what you don't like about it.

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Originally posted by ashraf02
          For my online store i would like about three items to be displayed in one row however because of the php code i wouldn't know how to display it like this. currently the items are displayed one after the other only 1 item per row which makes the page look a bit crap. can anyone please help. i will post the code below.

          thanks in advanced.


          [PHP] if (mysql_num_rows ($get_suit_res) > 0 ) {
          $display_block = "<p><em>Sor ry no items in this Smart</em></p>";

          while ($Suits = mysql_fetch_arr ay($get_suit_re s)) {
          $Suit_id = $Suits[Suit_ID];
          $Suit_title = stripslashes($S uits[Suit_Brand]);
          $Suit_price = $Suits[Suit_Price];
          $Suit_Image = $Suits[Suit_Image];

          $display_block .= "
          <table align=\"center\ ">
          <tr>
          <td>
          <a href=\"showitem .php?Suit_ID=$S uit_id\">$Suit_ title</a>
          <h2>£$Suit_pric e</h2>
          <img src=\"$Suit_Ima ge\" width=\"100\" height=\"200\"> </img>
          </td>
          </tr>
          </table>";
          }

          $display_block .= "<ul>";
          }

          }
          }
          }[/PHP]
          Hey there Ashraf!
          Have a look at this thread!

          Regards

          Comment

          • ashraf02
            New Member
            • Feb 2008
            • 53

            #6
            Originally posted by markusn00b
            Hey there Ashraf!
            Have a look at this thread!

            Regards
            thanks markus just havin a look now. i'll let u know how i got on.

            nice one mate.

            Comment

            • ashraf02
              New Member
              • Feb 2008
              • 53

              #7
              MARKUSN00B U r thee F%$&*£^ master i made it work man!

              Thanks alot mate.

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                Originally posted by ashraf02
                MARKUSN00B U r thee F%$&*£^ master i made it work man!

                Thanks alot mate.
                No problems! Haha.

                That thread has helped a fair few people, including myself!

                See you next time

                Regards :)

                Comment

                • ashraf02
                  New Member
                  • Feb 2008
                  • 53

                  #9
                  i'm having another slight problem similar to the one before. this time i want the following code to execute so that only one line of "Suits, Shirts and Trousers" is printed but for some reason it prints out three identical lines:

                  [PHP]$display_block = "<h1>Smartegori es</h1>
                  <p>select Smart to see items.</p>";

                  $get_Smarts = "SELECT Smart_ID, Smart_title, Smart_descripti on
                  FROM Smart
                  ORDER BY Smart_title";

                  $get_Smart_res = mysql_query ($get_Smarts) or die (mysql_error()) ;

                  if (mysql_num_rows ($get_Smart_res ) < 1) {
                  $display_block = "<p><em>Sor ry no Smarts to browse</em></p>";
                  } else {

                  while ($Smarts = mysql_fetch_arr ay ($get_Smart_res )) {
                  $Smart_ID = $Smarts [Smart_ID];
                  $Smart_title = strtoupper (stripslashes ($Smarts[Smart_title]));
                  $Smart_desc = stripslashes ($Smarts [Smart_descripti on]);

                  echo "
                  <table>
                  <tr>
                  <td><a href=\"$_SERVER[PHP_SELF]?Smart_ID=1\">< h2>Shirts</h2></a></strong></td>
                  </tr>
                  <tr>
                  <td><a href=\"$_SERVER[PHP_SELF]?Smart_ID=2\">< h2>Suits</h2></a></strong></td>
                  </tr>
                  <tr>
                  <td><a href=\"$_SERVER[PHP_SELF]?Smart_ID=3\">< h2>Trousers</h2></a></strong></td>
                  </tr>
                  <table>";[/PHP]


                  can someone please help. i hope that i'v made it clear.

                  Comment

                  • Markus
                    Recognized Expert Expert
                    • Jun 2007
                    • 6092

                    #10
                    After 'ORDER BY' use the LIMIT clause
                    [php]
                    ORDER BY Smart_title
                    LIMIT 1
                    [/php]

                    Regards :)

                    Comment

                    • ashraf02
                      New Member
                      • Feb 2008
                      • 53

                      #11
                      nice one markus much appreciated.

                      Comment

                      • Markus
                        Recognized Expert Expert
                        • Jun 2007
                        • 6092

                        #12
                        Originally posted by ashraf02
                        nice one markus much appreciated.
                        No problem!
                        See you around dude(tte)

                        Comment

                        Working...