Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-31-2005, 05:56 PM Alignment Problem
Novice Talker

Posts: 6
Trades: 0
I have a links exchange script . I am having a problem with when i add Catagories on the index page it keeps getting wider and wider It should stop adding after it being so wide and go to next line I am enclosing the coding I am not very good at html coding I did the php

Thxs Steve

PHP Code:
<?

if (file_exists('install/index.php'))
    
header('Location: install/index.php');
else
{
    require(
'libs/library.php');
    require(
'libs/footer.links.php');
    
    
$category  '';
    
$list        '';
    
$dir_list  '';
    
$page_info '';
    
$real_cate 'index';
    
$page        = (isset($_GET['page'])?$_GET['page']:1);
        
    
$cfg = new Config('config/settings.cfg');
    
$config $cfg->Get_Vars();
    
    
##------------------------
    ## INITIALIZE DATABASE
    ##------------------------
    
$conn mysql_connect($config['DB_HOST'],$config['DB_USER'],$config['DB_PWD']) or die('Cannot open database connection');
    
$db mysql_select_db($config['DB_NAME'],$conn) or die('Cannot open database');
    
    
$query 'SELECT set_metatags,set_header,set_footer,set_leftsection,set_rightsection FROM '.$config['DB_PREFIX'].'_link_settings';
    
$template mysql_query($query);
    list(
$meta_tags,$header,$footer,$left_section,$right_section) = mysql_fetch_row($template);
    
$meta_tags stripslashes($meta_tags);
    
$header stripslashes($header);
    
$footer stripslashes($footer);
    
$left_section stripslashes($left_section);
    
$right_section stripslashes($right_section);
    
    if (!isset(
$_GET['cate']))
        
$dir_list getDirlist(0,$config);
    else
    {
        
$cate_name $_GET['cate'];
        
        
$query "SELECT cate_id FROM ".$config['DB_PREFIX']."_link_categories WHERE LOWER(REPLACE(cate_name,' ','')) = '".strtolower(trim($cate_name))."'";
        
$rs mysql_query($query) or die ('Cannot execute query');
        list(
$cate_id) = mysql_fetch_row($rs);
        
        
$query "SELECT cate_edge FROM ".$config['DB_PREFIX']."_link_categories WHERE cate_id = $cate_id";
        
$rs_edge mysql_query($query);
        
        list(
$edge) = mysql_fetch_row($rs_edge);
        if (
strtolower($edge) == 'n')
            
$dir_list getDirlist($cate_id,$config);
        else
        {
            
$query "SELECT p.part_id, p.part_url, p.part_title, p.part_description, p.part_image FROM ".$config['DB_PREFIX']."_link_partners p, ".$config['DB_PREFIX']."_link_partners_categories pc WHERE pc.cate_id = $cate_id AND pc.part_id = p.part_id AND p.part_active = 3";
            
$rs_partners mysql_query($query) or die ('Cannot execute query');
            
            if (
mysql_num_rows($rs_partners) > 0)
            {
                
$query "SELECT set_paging FROM ".$config['DB_PREFIX']."_link_settings";
                
$rs_paging mysql_query($query) or die ('Cannot execute query');
                list(
$paging) = mysql_fetch_row($rs_paging);
                
                
$start = ($page 1) * $paging;
                
$tot_page ceil(mysql_num_rows($rs_partners) / $paging);
                    
                
$query "SELECT p.part_id, p.part_url, p.part_title, p.part_description, p.part_image FROM ".$config['DB_PREFIX']."_link_partners p, ".$config['DB_PREFIX']."_link_partners_categories pc WHERE pc.cate_id = $cate_id AND pc.part_id = p.part_id AND p.part_active = 3 LIMIT $start,$paging";
                
$rs_partners mysql_query($query) or die ('Cannot execute query');
                    
                
##----------------------------------------------------------------
                ## CALCULATE HOW MANY PAGE NUMBER WILL BE SHOWED - 1 2 3 4 5
                ##----------------------------------------------------------------
                
for ($i=1$i<=$tot_page$i++)
                {
                    if (
$i == $page)
                        
$page_no $page_no .'&nbsp;<b>'.$i.'</b>';
                    else
                    {
                        
// optimize for mod-rewrite so there is no duplicate pages
                        
if ($i != 1)
                            
$url trim(strtolower($cate_name)).'-'.$i.'.html';
                        else
                            
$url trim(strtolower($cate_name)).'.html';
                        
$url str_replace(' ','',$url);
                        
                        
$page_no $page_no ."&nbsp;<b><a class='category' href='$url'>".$i.'</a></b>';
                    }
                }

                
##----------------------------------------------------------------
                ## SHOW PAGE NO - page 1 of 1
                ##----------------------------------------------------------------
                
$page_info "<b>page $page of $tot_page</b>";
                
                
##----------------------------------------------------------------
                ## SHOW LINKS - 
                ##----------------------------------------------------------------
            
$list '<tr><td style=\'white-space: nowrap;\' align=\'left\' valign=\'top\' width=\'100%\'>';
                while (list(
$id,$url,$title,$description,$image) = mysql_fetch_row($rs_partners))
                {
                    
$url stripslashes($url);
                    
$title stripslashes($title);
                    
$description stripslashes($description);
                    
$image stripslashes($image);
                    if (
$image != '')
                        
$list .= "<p><span class=\"font12\"><a href=\"$url\" title=\"$title\" target=\"_blank\"><img src=\"http://www.webmaster-talk.com/images/logos/$image\" border=0><br><strong>$title</strong></a><br>$description</span></p>";
                    else
                        
$list .= "<p><span class=\"font12\"><a href=\"$url\" title=\"$title\" target=\"_blank\"><strong>$title</strong></a><br>$description</span></p>";
                }
                
$list .= '</td></tr>';
            }
        }
        
        
##--------------------------------------------------------------------------------------------------
        ##            GENERATING CATEGORY LINK -- START HERE 
        ##--------------------------------------------------------------------------------------------------
        
$real_cate $_GET['cate'];
        
$parent_id 1;
        
        while (
$parent_id != 0)
        {
            
##----------------------------------------------------------------
            ## GET PARENT CATEGORY
            ##----------------------------------------------------------------
            
$query "SELECT cate_id, cate_name, cate_parentid FROM ".$config['DB_PREFIX']."_link_categories WHERE cate_id = '$cate_id'";
            
$rs_cate mysql_query($query) or die('Cannot execute query');
            list(
$cate_id,$cate_name,$parent_id) = mysql_fetch_row($rs_cate);
            
            
##----------------------------------------------------------
            ##  FOR ACTIVE LINK, SHOULD BE DIFFERENTIATED
            ##----------------------------------------------------------
            
if ($cate_id == $real_cate)
                
$category " - <strong>$cate_name</strong>".$category;
            else
            {
                
$url trim(strtolower($cate_name)).'.html';
                
$url str_replace(' ','',$url);
                
$category " - <a class='category' href='$url'>$cate_name</a>".$category;        
            }
            
$cate_id $parent_id;
        }
    }
    
    if (
$category != '')
        
$category "<a class='category' href='index.php'>Links Directory</a>".$category;
    else
        
$category "Links Directory";
    
    if ((
$list == '') && ($dir_list == ''))
        
$dir_list '<tr><td align=\'left\' valign=\'top\' width=\'100%\' class=\"font12\">CURRENTLY NO LINKS AVAILABLE IN THIS SECTION</td></tr>';
}

    
function 
getDirlist($cate_id,$config)
{
    
$query "SELECT cate_id, cate_name, cate_image FROM ".$config['DB_PREFIX']."_link_categories WHERE cate_parentid = $cate_id";
    
$rs mysql_query($query) or die ('Cannot execute query');
            
    
##-----------------------------------------------------------------------------------
    ##            GENERATING CATEGORY LIST -- START HERE
    ##-----------------------------------------------------------------------------------
    
$dir '';
    if (
mysql_num_rows($rs) > 0)
    {
    
$dir '<tr><td style=\'white-space: nowrap;\' align=\'left\' valign=\'top\' width=\'100%\'>';
        while (list(
$id,$name,$image) = mysql_fetch_row($rs))
        {
            
$url trim(strtolower($name)).'.html';
            
$url str_replace(' ','',$url);
                
            if (
$image != '')
                
$dir .= "<p><a href='$url'><img src='images/$image' border=0><br><strong>$name</strong></a></p>";
            else
                
$dir .= "<a href='$url'><strong>$name</strong></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        }

        
$dir .= '</td></tr>';
    }
        
    return 
$dir;
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Links Directory</title>
<?=$meta_tags?>

<link href="styles.css" rel="stylesheet" type="text/css">

</head>
<body>
<CENTER><table>
<tr>
  <td><?=$header?></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="1" cellspacing="0" bgcolor="#FFFFFF">
<tr>
  <td>
    <table width="100%" height="100%" cellpadding="5">
    <tr>
      <td><?=$left_section?></td>
      <td width="80%" valign="top">
          <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
        <td width="80%" align="center" valign="top">
            <table width="100%"  border="0" cellspacing="0" cellpadding="25">
          <tr align="left">
            <td colspan="3">
              <table width="100%"  border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="76%" class="font11"><strong><?=$category?></strong></td>
                <td width="50%" align="right" class="font11"><a class="category" href="submit_url.php">submit your links here</a></td>
              </tr>
              <tr>
                <td colspan="2"><img src="http://www.webmaster-talk.com/images/p_2.gif" width="100%" height="1"></td>
              </tr>
              </table>                  
            </td>
          </tr>
          <? if ($list == '') echo $dir_list; else echo $list?>
          <tr align="left">
            <td colspan="3">
              <table width="100%"  border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td colspan="2"><img src="http://www.webmaster-talk.com/images/p_2.gif" width="100%" height="1"></td>
              </tr>
              <tr>
           <td width="76%"></td>
              </tr>
              </table>                  
            
          <tr align="left">
            <td colspan="3" valign="bottom" align="center" class="font12">
        
            </td>
            </tr>
          </table>
        </td>
      </tr>
      </table>
      </td>
          
      <td><?=$right_section?></td>
    </tr>

<table>
<tr>
  <td><?=$footer?></td>
</tr>
</table>
</CENTER></body>
</html>

Last edited by 0beron; 01-02-2006 at 04:01 AM..
stevan is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-01-2006, 06:05 PM
goldingh99's Avatar
Average Talker

Posts: 20
Trades: 0
im not exactly sure what you want - if it is that you want your text to go to the next line at a certain place then use this:

string wordwrap ( string str [, int width [, string break [, bool cut]]] )

for example
PHP Code:
<?php
$text 
"The quick brown fox jumped over the lazy dog.";
$newtext wordwrap($text20"<br />\n");

echo 
$newtext;
?>
would display

HTML Code:
The quick brown fox<br />
jumped over the lazy<br />
dog.
for more info on this go to http://uk2.php.net/manual/en/function.wordwrap.php
goldingh99 is offline
Reply With Quote
View Public Profile
 
Old 01-01-2006, 07:05 PM
Novice Talker

Posts: 6
Trades: 0
Right now it looks like this

Test test test test test
test test test test test

I wnat to look like this to make the space between the rows wider

Test test test test test


Test test test test test


Steve
stevan is offline
Reply With Quote
View Public Profile
 
Old 01-02-2006, 02:15 AM
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,111
Name: Matt. (>',')>
Location: London, England.
Trades: 0
PHP Code:
<?php
$text 
"The quick brown fox jumped over the lazy dog.";
$newtext wordwrap($text20"<br /><br />\n"); // ADD A  <br />

echo $newtext;
?>
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Old 01-02-2006, 07:51 AM
Novice Talker

Posts: 6
Trades: 0
I do not know where i would place it in the coding

##-----------------------------------------------------------------------------------
## GENERATING CATEGORY LIST -- START HERE
##-----------------------------------------------------------------------------------
$dir = '';
if (mysql_num_rows($rs) > 0)
{
$dir = '<tr><td align=\'center\' valign=\'top\' width=\'100%\'>';
while (list($id,$name,$image) = mysql_fetch_row($rs))
{
$url = trim(strtolower($name)).'.html';
$url = str_replace(' ','',$url);

if ($image != '')
$dir .= "<p><a href='$url' style='white-space: nowrap;'><img src='images/$image' border=0><br><strong>$name</strong></a></p>";
else
$dir .= "<a href='$url' style='white-space: nowrap;'><strong>$name</strong></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;";
}

$dir .= '</td></tr>';
}

return $dir;
}

?>
stevan is offline
Reply With Quote
View Public Profile
 
Old 01-02-2006, 06:32 PM
goldingh99's Avatar
Average Talker

Posts: 20
Trades: 0
before

return $dir;

add this

$newdir = wordwrap($dir, 20, "<br /><br />\n");

then instead of 'return $dir;' use

return $newdir;

hope this helps
goldingh99 is offline
Reply With Quote
View Public Profile
 
Old 01-02-2006, 06:48 PM
Novice Talker

Posts: 6
Trades: 0
That was not it made it worse
stevan is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Alignment Problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31375 seconds with 12 queries