
|
View Full Version : is it wrapping or something else?
ti_nhatrang 10-01-2006, 05:59 AM Hi guys,
My results are changing the width of my website, and it's driving me nuts!
$page_link="";
for($k=1;$k<=$tpage;$k++){
$page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a> ";
}
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?
<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...
maiahost 10-01-2006, 12:17 PM why don't you put a <br> tag at the end of the echo :
$page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a> <br>";
horizon 10-01-2006, 01:07 PM You could also change:
$page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a> <br>";
to:
$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> <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. ;)
ti_nhatrang 10-01-2006, 01:41 PM well, if I do that, then it's going to turn into a vertical line instead of horizontal...
horizon 10-01-2006, 02:43 PM Ah ! now I know what you're trying to do then.
Assuming you're using your URL under a while loop statement,
change:
$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> <br />";
to read:
$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> </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."\"
ti_nhatrang 10-01-2006, 07:47 PM 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...
$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> </TD>
";
} // End of while.
$page_link .= "
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
";
echo trim($page_link);
}
Calling the .php from .tpl...
<!-- 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...
horizon 10-01-2006, 08:03 PM 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 ?
ti_nhatrang 10-01-2006, 08:04 PM This is what I have:
STemplate::assign('page_link',$page_link);
horizon 10-01-2006, 08:20 PM Ok so, first, make a backup of those two files. Then, replace:
$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> </TD>
";
} // End of while.
$page_link .= "
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
";
echo trim($page_link);
}
with:
$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:
<TD WIDTH=\"100%\"><a href=\\"pages.php?page=".$k&viewtype."=".$viewtype."&category=".$category."">".$k."</a> </TD>
P.S: I'm not quite the expert with DIVs.
horizon 10-01-2006, 08:30 PM Code modified above.
ti_nhatrang 10-02-2006, 12:52 AM I can't have the $k in the tpl file.
ti_nhatrang 10-02-2006, 01:05 AM 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.
maiahost 10-02-2006, 03:52 AM You want to display 4 results per line ?
ti_nhatrang 10-02-2006, 03:53 AM yes please...
maiahost 10-02-2006, 04:19 AM OK here goes :
(your original 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> <br>";
}
else { $page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a> ";
}
$j++;
}
ti_nhatrang 10-02-2006, 04:56 AM OK here goes :
(your original 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> <br>";
}
else { $page_link.="<a href='pages.php?page=$k&viewtype=$_REQUEST[viewtype]&category=$category'>$k</a> ";
}
$j++;
}
You are AMAZING!!!
Thanks everyone for helping...
|