Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Styling page doesn't seem to work, plz help

  1. #1
    Join Date
    Dec 2009
    Posts
    48
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Styling page doesn't seem to work, plz help

    Hello,

    I've got a script to create pages from my database, it works great, but I cannot seem to get the styling in order. Can somebody help me out plz?

    On the first page, the images and text that is pulled from the database is nicely ordered in a table with a max of 4 columns. Great. However, on the second page (when you click an image of the outputted results), all of the records are listed on one line..... As the page only accepts 5 or 6 of those on one line due to the width of the page, all of the other records aren't seen.

    I've tried multiple things, but now I don't see it anymore. Can anybody see what to change to have a four column table again?

    Here's my script:

    PHP Code:
    <?php
    include("../connection.php");

    switch(
    $_GET['step']){
         default:
              
    $table "<table style='width:100%;'>\n";  
              
    $result mysql_query("SELECT DISTINCT thumb_sizecat, sizecat, link_size FROM Folders ORDER BY sizecat") or die (mysql_error());  
              while(
    $row mysql_fetch_array($result)){  
                   
    $row['price1'] = round ((($row['price1']+5) *1.85),0);
                   
    $base_m=5;
                   
    $row['price11'] = $base_m*(ceil(($row['price1'])/$base_m));
                   
    $table.="\t\t<td align='center' style='width:25%;'>"
                   
    ."<a href='?step=items&size=".urlencode($row['sizecat'])."'><img src='{$row['thumb_sizecat']}' alt='{$row['thumb_sizecat']}' />"
                   
    ."<br />{$row['sizecat']}</a></td>\n"
                   
    $colnum++;if($colnum == 0$table.="\t</tr>\n\t<tr>\n";  
              }  
              
    $table .= "\t</tr>\n</table>\n";
              echo 
    $table
         break;
         case 
    "items"
              
    $sizecat=mysql_real_escape_string($_GET['size']);
              echo 
    "<table style='width:100%;'>\r\n\t\t<tr>";
              
    $itemsQuery=mysql_query("SELECT * FROM `Folders` WHERE `sizecat`='{$sizecat}';");

              while(
    $item=@mysql_fetch_array($itemsQuery)){
                   
    $link="?step=color&size=".urlencode($sizecat)."&id=".urlencode($item['id']);
                   echo 
    "\t\t<td><a href='{$link}'><img src='{$item['thumb_size']}'  alt='{$item['thumb_size']}' /><br /><b>Size:</b>{$item['size']}<br /><b>Final size:</b>{$item['finalsize']}<br /></a></td>\r\n";
              
    $colnum++;if($colnum == 0$table.="\t</tr>\r\n\t<tr>\n";
              }

              echo 
    "</tr></table>\r\n";
         break;
         case 
    "color":
         
    // The rest here has almost the same codings, so I left it out
         
    break;
    }
    ?>
    Thx for helping out!!!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    In this sort of situation, I recommend looking at the generated html output (view>source while viewing the page) then working out what you want that source code to look like. Then go back to the PHP and find the places where you need to change it. Then actually fixing it should be easy (or at least easier).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Dec 2009
    Posts
    48
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    That is a really good idea, though in this case it doesn't really help me....

    I see the table settings, then for the columns I see:

    Code:
    <td align='center' style='width:25%;'>content</td>
    <td align='center' style='width:25%;'>content</td>
    and so on.
    So yeah, that is exactly what it is displaying and what I thought it would output. I don't see the <tr> and </tr> anywhere....

    Though... I have no idea how to input that....

    I've stated the columns this way:

    PHP Code:
    $colnum++;if($colnum == 0$table.="\t</tr>\n\t<tr>\n"
    And for the first page, that is exactly what it's displaying.... So I don't know what to edit to get that same result for the second (and other) pages.

    Do you? Or did I miss something?

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It looks like that should work. Try echoing the value of $colname with each loop so you can watch what it does.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Dec 2009
    Posts
    48
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    That's what I thought....

    You mean '$colnum'? And how do I do that? Just placing an echo in front of that line gives me the numbers 1 - 100 for some reason and nothing else is changed.

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Ah, yes, typo.

    Well, just add echo '####'.$colnum.'####'; after the line with it, so you can see the the number is. Track it and see what happens. (Note: I added the extra symbols just to make it easy to read-- they're not 'doing' anything.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Dec 2009
    Posts
    48
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Yeah thought so. lol

    Well.... I'm not sure what I should do with that info... It gives me the numbers 1 to 98 vertically with the four # before and after the numbers. What should I learn from this?

  8. #8
    Join Date
    Dec 2009
    Posts
    48
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Um, what should I do now with those numbers? Or can somebody else help me out here?

    Thx in advance!

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Sorry I haven't noticed this until now.

    That means you can follow PHP as it generates the <td>s. So look through it and see if you are getting any <tr>s, and if not, see if you can figure out why.

    Another thing you can try is this:
    PHP Code:
    $colnum++;
    if(
    $colnum == 0) {
    $table.="\t</tr>\n\t<tr>\n";
    echo 
    '######TR#####';

    If you see "######TR#####" somewhere in your output, then that means that the if statement IS working and something is wrong with the $table.= part. I still don't see anything wrong with it.

    So all I'm suggesting here is that you take it apart line by line (and echo things) so that you can check what PHP is doing along the way. Eventually you'll be able to find the part that doesn't make sense.

    Without testing on your server it's hard to help you-- so just try yourself by checking like this and finding where PHP is doing something unexpected.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Dec 2009
    Posts
    48
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    No worries, I thought you might missed the post. I'm really glad that you're back though I tried hundreds of things, but it either gives a fatal error or the same result is outputted.

    Okay, well I just found out that on the first page that is being outputted, there's no starting '<tr>'. That might be the first odd thing. On the second outputted page, there's no <tr> nor </tr> at all. I tried using the echo's to see what it's doing, so now I know about the <tr>'s, but I still don't know what to do now, since I don't see anything in the table part that is off.

    Testing... you mean you need the link to see what it's doing?

    If this all isn't working... is there another way to output the table settings? If so, do you know how? I already tried using statements to output a table and then use normal html to get the table itself. But that gives me a whole lot of code (like 2 pages for every switch) and still minor errors (displaying double results). So I'm kinda out of idea's, lol.

    Thx very much for helping!

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
  •