Loading ...
Sorry, an error occurred while loading the content.

more php question

Expand Messages
  • Miro Perdoch
    hello guys i know this is more php then xhthml question but php is becoming a significant part of the web page design these days. I have a page that displays
    Message 1 of 5 , Aug 9, 2006
    • 0 Attachment
      hello guys

      i know this is more php then xhthml question but php is becoming a
      significant part of the web page design these days.

      I have a page that displays database results in rows here:

      http://www.castingfiles.com (then click on the talent Search link on the
      left navigation bar, then press search button) the best is viewed in M-IE

      now I would like the results being displayed in rows and columns like on
      this page:

      http://www.liberationagency-uk.co.uk/links/fash_fem_model.htm

      i tried a few things but can not work it out. Would i need to play with
      arrays or something?

      any help would be welcome

      thank you

      Miro Perdoch

      ORIM Web Design
      http://www.orim.co.uk
      miro@...
      miro500@...
    • David Colliver
      Hi, I am not a PHP programmer, but the scenario is familiar in many other languages as well. This is really quite simple to achieve without having to resort to
      Message 2 of 5 , Aug 9, 2006
      • 0 Attachment
        Hi,

        I am not a PHP programmer, but the scenario is familiar in many other
        languages as well.

        This is really quite simple to achieve without having to resort to arrays.

        Have a think how you would normally do it, purely with HTML.

        Now, take a look at the structure.

        Lets say that you are going for 5 photos across like this site. You have to
        make 1 table row, 5 columns wide.

        pseudo code....

        columncount = 0

        write <table><tr>

        while data set not eof

        write <td> IMAGE </td>
        columncount + 1

        if columncount = 5 then
        columncount = 0
        // New row
        write </tr><tr>
        end if

        end

        write </tr></table>

        How's that? You will have to write the logic to stop an empty row being
        written.

        Oh, BTW, there may be kids watching. A more suitable site would have been a
        better option to show us.

        Best regards,
        Dave Colliver.
        http://www.AshfieldFOCUS.com
        ~~
        http://www.FOCUSPortals.com - Local franchises available


        ----- Original Message -----
        From: "Miro Perdoch" <miro500@...>
        To: <cightml@yahoogroups.com>
        Sent: Wednesday, August 09, 2006 8:05 PM
        Subject: [cightml] more php question


        > hello guys
        >
        > i know this is more php then xhthml question but php is becoming a
        > significant part of the web page design these days.
        >
        > I have a page that displays database results in rows here:
        >
        > http://www.castingfiles.com (then click on the talent Search link on the
        > left navigation bar, then press search button) the best is viewed in M-IE
        >
        > now I would like the results being displayed in rows and columns like on
        > this page:
        >
        > http://www.liberationagency-uk.co.uk/links/fash_fem_model.htm
        >
        > i tried a few things but can not work it out. Would i need to play with
        > arrays or something?
        >
        > any help would be welcome
        >
        > thank you
        >
        > Miro Perdoch
        >
        > ORIM Web Design
        > http://www.orim.co.uk
        > miro@...
        > miro500@...
        >
        >
        >
        >
        > To unsubscribe from the Yahoo Group, send an email to:
        > cightml-unsubscribe@yahoogroups.com
        >
        > This list is for readers of Paul McFedries' CIG to Creating a Web Page.
        >
        > Messages prior to 2002 are also archived at http://www.mcfedries.com
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >
        >
      • Miro Perdoch
        thank you for your help. i just found something similar - using php Modulus Operator: the code suggestion follows: //set the number of columns $columns = 5;
        Message 3 of 5 , Aug 9, 2006
        • 0 Attachment
          thank you for your help.

          i just found something similar - using php Modulus Operator:

          the code suggestion follows:

          //set the number of columns
          $columns = 5;

          mysql_connect('localhost','','');
          mysql_select_db('test');
          $query = "SELECT stuff FROM mystuff ORDER BY stuff";
          $result = mysql_query($query);

          //we add this line because we need to know the number of rows
          $num_rows = mysql_num_rows($result);
          echo "<TABLE BORDER=\"0\">\n";

          //changed this to a for loop so we can use the number of rows
          for($i = 0; $i < $num_rows; $i++) {
          $row = mysql_fetch_array($result);
          if($i % $columns == 0) {
          //if there is no remainder, we want to start a new row
          echo "<TR>\n";
          }
          echo "<TD>" . $row['stuff'] . "</TD>\n";
          if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) {
          //if there is a remainder of 1, end the row
          //or if there is nothing left in our result set, end the row
          echo "</TR>\n";
          }
          }
          echo "</TABLE>\n";



          i have not tested this yet but it might resolve the issue.

          regards


          Miro Perdoch

          ORIM Web Design
          http://www.orim.co.uk
          miro@...
          miro500@...
        • David Colliver
          Yes, it is more or less the same. As said, it is quite a common scenario, Admittedly, it needs a little thought if you have never done that before. Best
          Message 4 of 5 , Aug 10, 2006
          • 0 Attachment
            Yes, it is more or less the same.

            As said, it is quite a common scenario, Admittedly, it needs a little
            thought if you have never done that before.

            Best regards,
            Dave Colliver.
            http://www.BristolFOCUS.com
            ~~
            http://www.FOCUSPortals.com - Local franchises available


            ----- Original Message -----
            From: "Miro Perdoch" <miro500@...>
            To: <cightml@yahoogroups.com>
            Sent: Thursday, August 10, 2006 7:17 AM
            Subject: Re: [cightml] more php question


            > thank you for your help.
            >
            > i just found something similar - using php Modulus Operator:
            >
            > the code suggestion follows:
            >
            > //set the number of columns
            > $columns = 5;
            >
            > mysql_connect('localhost','','');
            > mysql_select_db('test');
            > $query = "SELECT stuff FROM mystuff ORDER BY stuff";
            > $result = mysql_query($query);
            >
            > //we add this line because we need to know the number of rows
            > $num_rows = mysql_num_rows($result);
            > echo "<TABLE BORDER=\"0\">\n";
            >
            > //changed this to a for loop so we can use the number of rows
            > for($i = 0; $i < $num_rows; $i++) {
            > $row = mysql_fetch_array($result);
            > if($i % $columns == 0) {
            > //if there is no remainder, we want to start a new row
            > echo "<TR>\n";
            > }
            > echo "<TD>" . $row['stuff'] . "</TD>\n";
            > if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) {
            > //if there is a remainder of 1, end the row
            > //or if there is nothing left in our result set, end the row
            > echo "</TR>\n";
            > }
            > }
            > echo "</TABLE>\n";
            >
            >
            >
            > i have not tested this yet but it might resolve the issue.
            >
            > regards
            >
            >
            > Miro Perdoch
            >
            > ORIM Web Design
            > http://www.orim.co.uk
            > miro@...
            > miro500@...
            >
            >
            >
            >
            > To unsubscribe from the Yahoo Group, send an email to:
            > cightml-unsubscribe@yahoogroups.com
            >
            > This list is for readers of Paul McFedries' CIG to Creating a Web Page.
            >
            > Messages prior to 2002 are also archived at http://www.mcfedries.com
            >
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            >
            >
            >
            >
            >
          • Don - HtmlFixIt.com
            ... That should work about as expected. I did not syntax check it, but each 6th picture will end up on a new row using that modulus operator as you do.
            Message 5 of 5 , Aug 10, 2006
            • 0 Attachment
              Miro Perdoch wrote:
              > thank you for your help.
              >
              > i just found something similar - using php Modulus Operator:
              >
              > the code suggestion follows:
              >
              > //set the number of columns
              > $columns = 5;
              >
              > mysql_connect('localhost','','');
              > mysql_select_db('test');
              > $query = "SELECT stuff FROM mystuff ORDER BY stuff";
              > $result = mysql_query($query);
              >
              > //we add this line because we need to know the number of rows
              > $num_rows = mysql_num_rows($result);

              That should work about as expected. I did not syntax check it, but each
              6th picture will end up on a new row using that modulus operator as you do.
            Your message has been successfully submitted and would be delivered to recipients shortly.