Results 1 to 16 of 16
  1. #1
    Join Date
    Apr 2005
    Posts
    694

    is it wrapping or something else?

    Hi guys,

    My results are changing the width of my website, and it's driving me nuts!

    PHP Code:
    $page_link="";
    for(
    $k=1;$k<=$tpage;$k++){ 
            
            
    $page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a>&nbsp;&nbsp;";

    That's my php code, and I get over 100 results, and it's going from left to right and it doesn't drop down to another line, it just go straight right and I have to use the scroll bar to see the full results... Is there anyway we can parse this somehow it fits in the width="700" only?

    PHP Code:
     <DIV
                style
    ="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 13px; PADDING-BOTTOM: 5px; COLOR: #444; PADDING-TOP: 5px; TEXT-ALIGN: right">Browse
                Pages
    :
                {
    $page_link}
                </
    DIV
    That's what I have to call the results...

    Please help...

  2. #2
    why don't you put a <br> tag at the end of the echo :
    Code:
    $page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a>&nbsp;&nbsp;<br>";
    Cheap web hosting
    Any CMS pre-installed
    Joomla Hosting

  3. #3
    Join Date
    Mar 2006
    Posts
    965
    You could also change:

    PHP Code:
    $page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a>&nbsp;&nbsp;<br>"
    to:

    PHP Code:
    $viewtype = (isset($_REQUEST['viewtype'])) ? (stripslashes(trim($_GET['viewtype']))) : ""// Assuming the viewtype is a string name and not an int value.
    $category = (isset($_REQUEST['category'])) ? intval(trim($_GET['category'])) : 0// Assuming the category is about the cat_id.

    $page_link.="<a href=\\"pages.php?page=".$k&viewtype."=".$viewtype."&category=".$category."\">$k</a>&nbsp;&nbsp;<br />"
    Edit:

    Strange.

    &category=".$category."\" doesn't seem to be considered into the code above by using the [ php ] tag in the text window.

    Perhaps if I tell you replace, from my code above - when you're done, this part:

    &category=".$category.""
    with this part:

    &category=".$category."\"
    Let's see.
    Last edited by horizon; 10-01-2006 at 01:11 PM.

  4. #4
    Join Date
    Apr 2005
    Posts
    694
    well, if I do that, then it's going to turn into a vertical line instead of horizontal...

  5. #5
    Join Date
    Mar 2006
    Posts
    965
    Ah ! now I know what you're trying to do then.

    Assuming you're using your URL under a while loop statement,

    change:

    PHP Code:
    $viewtype = (isset($_REQUEST['viewtype'])) ? (stripslashes(trim($_GET['viewtype']))) : ""// Assuming the viewtype is a string name and not an int value.
    $category = (isset($_REQUEST['category'])) ? intval(trim($_GET['category'])) : 0// Assuming the category is about the cat_id.

    $page_link.="<a href=\\"pages.php?page=".$k&viewtype."=".$viewtype."&category=".$category."">$k</a>&nbsp;&nbsp;<br />"
    to read:


    PHP Code:
    $viewtype = (isset($_REQUEST['viewtype'])) ? (stripslashes(trim($_GET['viewtype']))) : ""// Assuming the viewtype is a string name and not an int value.
    $category = (isset($_REQUEST['category'])) ? intval(trim($_GET['category'])) : 0// Assuming the category is about the cat_id.

    $page_link .= "
    <TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"0\" CELLSPACING=\"0\">
    <TR>
    <TD WIDTH=\"100%\">
    <TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"0\" CELLSPACING=\"0\">
    <TR>
    "
    ;
    // Put your while statement here . . .
    $page_link .= "
     <TD WIDTH=\"100%\"><a href=\\"
    pages.php?page=".$k&viewtype."=".$viewtype."&category=".$category."">".$k."</a>&nbsp;&nbsp;</TD>
    "
    ;
    // End of while.
    $page_link .= "
    </TR>
    </TABLE>
    </TD>
    </TR>
    </TABLE>
    "
    ;
    echo 
    trim($page_link); 
    This way, the URL presentation should never break a line 'until' the maximum table size limit has been reached (100% has been set as width in this case).

    P.S: Don't forget about the:

    &category=".$category.""

    for:

    &category=".$category."\"

  6. #6
    Join Date
    Apr 2005
    Posts
    694
    I'm not sure if this help, but I'm using smart templates engine, therefore, the echo is in the othe file, file.tpl....

    Here's how it's looking now with the changes you've recommended...

    PHP Code:
    $page_link="";
    for(
    $k=1;$k<=$tpage;$k++){ 
            
            
    $viewtype = (isset($_REQUEST['viewtype'])) ? (stripslashes(trim($_GET['viewtype']))) : ""// Assuming the viewtype is a string name and not an int value.
    $category = (isset($_REQUEST['category'])) ? intval(trim($_GET['category'])) : 0// Assuming the category is about the cat_id.

    $page_link .= "
    <TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"0\" CELLSPACING=\"0\">
    <TR>
    <TD WIDTH=\"100%\">
    <TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"0\" CELLSPACING=\"0\">
    <TR>
    "
    ;
    // Put your while statement here . . .
    $page_link .= "
     <TD WIDTH=\"100%\"><a href=\\"
    pages.php?page=".$k&viewtype."=".$viewtype."&category=".$category."\">".$k."</a>&nbsp;&nbsp;</TD>
    "
    ;
    // End of while.
    $page_link .= "
    </TR>
    </TABLE>
    </TD>
    </TR>
    </TABLE>
    "
    ;
    echo 
    trim($page_link);

    Calling the .php from .tpl...

    PHP Code:
        <!-- begin paging -->
                <
    DIV
                style
    ="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 13px; PADDING-BOTTOM: 5px; COLOR: #444; PADDING-TOP: 5px; TEXT-ALIGN: right">Browse
                Pages
    :
                {
    $page_link}
                </
    DIV><!-- end paging --> 

    Doesn't seem to work with what you told me to do...

  7. #7
    Join Date
    Mar 2006
    Posts
    965
    I wasn't aware, from your info above, you had a TPL file aside that parses your template. Do you have a class name, linked with a method name, that parse that TPL file technicly ?

  8. #8
    Join Date
    Apr 2005
    Posts
    694
    This is what I have:

    PHP Code:
    STemplate::assign('page_link',$page_link); 

  9. #9
    Join Date
    Mar 2006
    Posts
    965
    Ok so, first, make a backup of those two files. Then, replace:

    PHP Code:
    $page_link=""
    for(
    $k=1;$k<=$tpage;$k++){  
             
            
    $viewtype = (isset($_REQUEST['viewtype'])) ? (stripslashes(trim($_GET['viewtype']))) : ""// Assuming the viewtype is a string name and not an int value. 
    $category = (isset($_REQUEST['category'])) ? intval(trim($_GET['category'])) : 0// Assuming the category is about the cat_id. 

    $page_link .= 
    <TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"0\" CELLSPACING=\"0\"> 
    <TR> 
    <TD WIDTH=\"100%\"> 
    <TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"0\" CELLSPACING=\"0\"> 
    <TR> 
    "

    // Put your while statement here . . . 
    $page_link .= 
     <TD WIDTH=\"100%\"><a href=\\"
    pages.php?page=".$k&viewtype."=".$viewtype."&category=".$category."">".$k."</a>&nbsp;&nbsp;</TD> 
    "

    // End of while. 
    $page_link .= 
    </TR> 
    </TABLE> 
    </TD> 
    </TR> 
    </TABLE> 
    "

    echo 
    trim($page_link); 

    with:

    PHP Code:
    $page_link "";

    $viewtype = (isset($_REQUEST['viewtype'])) ? (stripslashes(trim($_GET['viewtype']))) : ""// Assuming the viewtype is a string name and not an int value. 
    $category = (isset($_REQUEST['category'])) ? intval(trim($_GET['category'])) : 0// Assuming the category is about the cat_id.

    $page_link .= 
    <TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"0\" CELLSPACING=\"0\"> 
    <TR> 
    <TD WIDTH=\"100%\"> 
    <TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"0\" CELLSPACING=\"0\"> 
    <TR> 
    "

     
    for (
    $k 1$k <= $tpage$k++) {
    $page_link .= STemplate::assign('page_link',$page_link);   
    }
    $page_link .= 
    </TR> 
    </TABLE> 
    </TD> 
    </TR> 
    </TABLE> 
    "

    unset (
    $page_link); 
    Then, replace your TPL file with:

    PHP Code:
    <TD WIDTH=\"100%\"><a href=\\"pages.php?page=".$k&viewtype."=".$viewtype."&category=".$category."">".$k."</a>&nbsp;&nbsp;</TD> 
    P.S: I'm not quite the expert with DIVs.
    Last edited by horizon; 10-01-2006 at 08:29 PM.

  10. #10
    Join Date
    Mar 2006
    Posts
    965
    Code modified above.

  11. #11
    Join Date
    Apr 2005
    Posts
    694
    I can't have the $k in the tpl file.

  12. #12
    Join Date
    Apr 2005
    Posts
    694
    I think we have to do something like, First 20,21,22,23,current,25,26,27,28,last, etc... let me know if you understand what I mean.

  13. #13
    You want to display 4 results per line ?
    Cheap web hosting
    Any CMS pre-installed
    Joomla Hosting

  14. #14
    Join Date
    Apr 2005
    Posts
    694
    yes please...

  15. #15
    OK here goes :
    (your original code)

    Code:
    $j=0;
    for($k=1;$k<=$tpage;$k++){  
             
         
    if ($j%4==0)
    { $page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a>&nbsp;&nbsp;<br>"; 
    }
    else { $page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a>&nbsp;&nbsp;"; 
    }
    $j++;
    }
    Cheap web hosting
    Any CMS pre-installed
    Joomla Hosting

  16. #16
    Join Date
    Apr 2005
    Posts
    694
    Quote Originally Posted by maiahost
    OK here goes :
    (your original code)

    Code:
    $j=0;
    for($k=1;$k<=$tpage;$k++){  
             
         
    if ($j%4==0)
    { $page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a>&nbsp;&nbsp;<br>"; 
    }
    else { $page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a>&nbsp;&nbsp;"; 
    }
    $j++;
    }

    You are AMAZING!!!

    Thanks everyone for helping...

Posting Permissions

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