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.

HTML Forum


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



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Simple table tags problem
Old 12-10-2009, 11:11 AM Simple table tags problem
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
I for some reason cannot get this to display correctly...What I want is the image displayed then the text under it, I could manage to get it any and every other possible way but the right way. :S

Code:
echo "<table>";
while($row = mysql_fetch_array($result)) {

echo "<tr>";
echo "<img src=\"http://www.webmaster-talk.com/images/$row[element_5]\" border=\"1\" width='$maxwidth' alt=\"$row[element_1]\" title=\"$row[element_1]\">";

echo "<tr>";
echo "<a href=\"$row[element_2]\">$row[element_1]</a>";

}
element_1 = Text
element_2 = URL
element_5 = Image
Attached Images
File Type: png sample.png (3.2 KB, 1 views)
__________________
Made2Own

Please login or register to view this content. Registration is FREE

Last edited by Brian07002; 12-10-2009 at 11:35 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-10-2009, 11:40 AM Re: Simple table tags problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,382
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Has everybody now forgotten how to construct a table??
HTML Code:
<table>
<tr>
<td>Content col1</td>
<td>Content col2</td>
</tr>
</table>
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-10-2009, 01:01 PM Re: Simple table tags problem
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
I'm not quite that bad at my html chris, but probably still that bad in my php / html combined.

Anyway here's the php code that I am working with: It's the last block of the echoed html code near the bottom..I have commented out the block of echoed html code right above that as it's not required for the below code to function (main difference is the maxwidth part). Note the echoed "<table>"; code near the top.

Code:
<?php
                             // Begin Resize Image To Specific Dimensions Code //

    $dir = "images/"; //dir of your images
    $exten1 = "jpg"; //extension -> jpg / gif / png
    $exten2 = "png"; //extension
    $exten3 = "gif"; //extension
    
    $maxwidth = '190'; //maximum width
    if ($handle = @opendir($dir)) 

    echo "<table>";
    
    {
    
    while (false !== ($file = @readdir($handle))) { 
    $bestand = $dir ."/". $file;
    $ext = pathinfo($bestand);
    if($ext['extension'] == $exten1 || $ext['extension'] == $exten2 || $ext['extension'] == $exten3)
    
    while($row = mysql_fetch_array($result)) {
    {

    $width = getimagesize($bestand);
    if($width[0]<$maxwidth)
    
    {
    
    /*
    echo "<td align=\"center\">";
    echo "<a href=\"http://localhost/scripts/index.php?id=$row[$id]\"><img border=\"1\" src=\"images/$row[element_5]\" alt=\"$row[element_1]\" title=\"$row[element_1]\">";
    echo "<p />";
    echo "<a href=\"$row[element_2]\">$row[element_1]</a>";
    */
    
    }

    else

    {

    echo "<tr>";
    echo "<td><img src=\"images/$row[element_5]\" border=\"1\" width='$maxwidth' alt=\"$row[element_1]\" title=\"$row[element_1]\"></td>";
    echo "<td><a href=\"$row[element_2]\">$row[element_1]</a></td>";

    } 
    }
    } 
    }

    @closedir($handle); 
    }
 
    echo "</tr>";
    echo "</td>";
    echo "</table>";
    
                             // End Resize Image To Specific Dimensions Code //

?>
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-10-2009, 02:09 PM Re: Simple table tags problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,382
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
I'm not quite that bad at my html
No, I just found it amusing because there was a post earlier in the week where somebody had created a mish mash of <li>s and floated <div>s in an attempt to create a very simple three column table.

I usually don't start messing about echoing the structure because it's easy to get thoroughly lost with what is printing where.

Write out the structure in HTML and just echo the content into the cells
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-10-2009, 02:15 PM Re: Simple table tags problem
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Write out the structure in HTML and just echo the content into the cells

? Bit Lost Here ?
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-10-2009, 02:21 PM Re: Simple table tags problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,382
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
PHP Code:
<table>
<tr>
<td><?php echo('something')?></td>
<td><?php echo('something else')?></td>
</tr>
</table>
It does not add anything significant to the processing time
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-10-2009, 08:54 PM Re: Simple table tags problem
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
I tried fixing up the code a bit more to make it more readable, but I still haven't solved the issue.

Someone see something that I might have missed? I don't want one row of images with a column of text next to it, but image then text under it, then image NEXT to FIRST image with text under that, etc..etc..

Note, I didn't forget the closing curly bracket, I left it out of this code

PHP Code:
echo "<table cellpadding=\"5\" cellspacing=\"5\" width=\"100%\" border=\"1\" style=\"border-collapse:collapse;\">";
while(
$row mysql_fetch_array($result)) {
echo 
"<tr><td>";
echo 
"<img src=\"http://www.webmaster-talk.com/images/$row[element_5]\" border=\"1\" width='$maxwidth' alt=\"$row[element_1]\" title=\"$row[element_1]\">";

// by adding the <br /> tag just before $row[element_1] below, I now have the text UNDER the image, but I want to put the images into separate rows not just one 

echo "<a href=\"$row[element_2]\"><br />$row[element_1]</a>"
__________________
Made2Own

Please login or register to view this content. Registration is FREE

Last edited by Brian07002; 12-10-2009 at 08:58 PM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-11-2009, 02:10 PM Re: Simple table tags problem
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
This is the CLOSEST I could come...
Code:
echo "<table align=\"center\" cellpadding=\"5\" cellspacing=\"5\" style=\"border-collapse:collapse;\" width=\"100%\">";
echo "<tr>";
while($row = mysql_fetch_array($result)) {
echo "<td align=\"center\">";
echo "<img src=\"images/$row[element_5]\" border=\"1\" width='$maxwidth' alt=\"$row[element_1]\" title=\"$row[element_1]\">";
echo "<a href=\"$row[element_2]\"><p align=\"center\">$row[element_1]</a>";    
           
    }
Anyone have a solution to getting it to create new rows? I have 6 images currently output to the page, and I only want 5 in this case (or the most to go across without scrolling) then creating a new row.
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-11-2009, 04:47 PM Re: Simple table tags problem
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Write out the structure in HTML and just echo the content into the cells
If I did that, I would have to wait until the database get's populated...Doesn't make sense to do it that way, but yeah if I had the image pre populated it would work that way.

Still looking for help on this.
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-11-2009, 07:53 PM Re: Simple table tags problem
Banned

Posts: 1
Name: vimflaxspra
Trades: 0
I for some reason cannot get this to display correctly...What I want is the image displayed then the text under it, I could manage to get it any and every other possible way but the right way. :S
trimthergrt is offline
Reply With Quote
View Public Profile
 
Old 12-11-2009, 09:39 PM Re: Simple table tags problem
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Why are you using my words without using the quote tags?
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-12-2009, 03:53 AM Re: Simple table tags problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,382
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by Brian07002 View Post
Why are you using my words without using the quote tags?
It was just another sig link spammer.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-12-2009, 06:55 AM Re: Simple table tags problem
Junior Talker

Posts: 1
Trades: 0
You need also use (table)(tr) and (td)
tinyurnet is offline
Reply With Quote
View Public Profile
 
Old 12-12-2009, 10:57 AM Re: Simple table tags problem
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by tinyurnet View Post
You need also use (table)(tr) and (td)
care to show where they would go in a situation like the one I am trying to get it in?
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-12-2009, 12:14 PM Re: Simple table tags problem
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Quote:
Originally Posted by Brian07002 View Post
If I did that, I would have to wait until the database get's populated...Doesn't make sense to do it that way, but yeah if I had the image pre populated it would work that way.

Still looking for help on this.
Not sure what you mean by that. Did you know you can do this?
PHP Code:
<?php while($row mysql_fetch_assoc($result)) {
?>
<tr>
    <td><?php echo $row['something'];?></td>
    <td><?php echo $row['something_else'];?></td>
    <td><?php echo $row['yet_something_else'];?></td>
</tr>
<?php }?>
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.

Last edited by wayfarer07; 12-12-2009 at 12:15 PM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 12-12-2009, 02:00 PM Re: Simple table tags problem
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Amazing how all this code can all serve the purpose for one problem.

Anyway, how about adding it to this:

Code:
<html>
<head><title>Get Linked up or Get lost in webspace!</title>
</head>

<?php
$background_color = "#FFFFFF"; // default WHITE background
switch(date(“md”)) {
     
     case 0101:
       // New Years Day background color (light green) on 01/01
       $background_color = "#D5FFD5";
     break;

     case 0202:
       // Ground Hog Day background color (dirty green) on 02/02
       $background_color = "#178E02";
     break;

     case 0214:
       // Valentines Day background color (Pink'ish Purple) on 02/14
       $background_color = "#FE5DCB";
     break;

     case 0422:
       // Earth Day background color (Earth Blue) on 04/22
       $background_color = "#2C7DF8";
     break;

     case 0704:
       // July 4th - Independence Day background color (Yellow) on 07/04
       $background_color = "#FFF20A";
     break;

     case 1111:
       // Veterans Day background color (white) on 11/11
       $background_color = "#FFFFFF";
     break;

     case 1031:
       // automatic halloween background color (light orange) on 10/31
       $background_color = "#FFE6CC";
     break;

     case 1225:
       // xmas day background color (light green) on 12/25
       $background_color = "#D5FFD5";
     break;
}

?>

<body bgcolor="<?php echo($background_color);?>">































<?php

include('config.php');

                                       // Begin Pagination Code //


    $tbl_name="ap_form_1";        //your table name
    // How many adjacent pages should be shown on each side?
    $adjacents = 1;
    
    /*
      First get total number of rows in data table.
      If you have a WHERE clause in your query, make sure you mirror it here.
    */

    $query = "SELECT COUNT(*) as num FROM $tbl_name";
    $total_pages = mysql_fetch_array(mysql_query($query));
    $total_pages = $total_pages[num];
    
    /* Setup vars for query. */
    $targetpage = "index.php";     //your file name (the name of this file)
    $limit = 5;             //how many items to show per page
    $page = $_GET['page'];
    if($page)
        $start = ($page - 1) * $limit;             //first item to display on this page
    else
        $start = 0;                                //if no page var is given, set start to 0
    
    /* Get data. */
    $sql = "SELECT * FROM $tbl_name ORDER BY ABS(`element_4`) DESC LIMIT $start, $limit";
    $result = mysql_query($sql);


    /* Setup page vars for display. */
    if ($page == 0) $page = 1;                    //if no page var is given, default to 1.
    $prev = $page - 1;                            //previous page is page - 1
    $next = $page + 1;                            //next page is page + 1
    $lastpage = ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.
    $lpm1 = $lastpage - 1;                        //last page minus 1
    
    /*
        Now we apply our rules and draw the pagination object.
        We're actually saving the code to a variable in case we want to draw it more than once.
    */

    $pagination = "";
    if($lastpage > 1)
    {    
    $pagination .= "<div class=\"pagination\">";
    //previous button
    if ($page > 1)
    $pagination.= "<a href=\"$targetpage?page=$prev\"><< previous </a>";
    else
    $pagination.= "<span class=\"disabled\"><< previous </span>";    
      
    //pages    
    if ($lastpage < 7 + ($adjacents * 2))    //not enough pages to bother breaking it up
    {    
    for ($counter = 1; $counter <= $lastpage; $counter++)
    {
    if ($counter == $page)
    $pagination.= "<span class=\"current\">$counter</span>";
    else
    $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
    }
    }
    elseif($lastpage > 5 + ($adjacents * 2))    //enough pages to hide some
    {
    //close to beginning; only hide later pages
    if($page < 1 + ($adjacents * 2))        
    {
    for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
    {
    if ($counter == $page)
    $pagination.= "<span class=\"current\">$counter</span>";
    else
    $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
    }
    $pagination.= "...";
    $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
    $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";        
    }
    //in middle; hide some front and some back
    elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
    {
    $pagination.= "<a href=\"$targetpage?page=1\">1</a>";
    $pagination.= "<a href=\"$targetpage?page=2\">2</a>";
    $pagination.= "...";
    for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
    {
    if ($counter == $page)
    $pagination.= "<span class=\"current\">$counter</span>";
    else
    $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
    }
    $pagination.= "...";
    $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
    $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";        
    }
    //close to end; only hide early pages
    else
    {
    $pagination.= "<a href=\"$targetpage?page=1\">1</a>";
    $pagination.= "<a href=\"$targetpage?page=2\">2</a>";
    $pagination.= "...";
    for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
    {
    if ($counter == $page)
    $pagination.= "<span class=\"current\">$counter</span>";
    else
    $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
    }
    }
    }
       
    //next button
    if ($page < $counter - 1)
    $pagination.= "<a href=\"$targetpage?page=$next\"> next >></a>";
    else
    $pagination.= "<span class=\"disabled\"> next >></span>";
    $pagination.= "</div>\n";        
    }

                                       // End Pagination Code //
?>





























<?php
                             // Begin Resize Image To Specific Dimensions Code //

    
    $dir = "images/"; //dir of your images
    $exten1 = "jpg"; //extension -> jpg / gif / png
    $exten2 = "png"; //extension
    $exten3 = "gif"; //extension
    
    $maxwidth = '190'; //maximum width
    if ($handle = @opendir($dir)) 
    
    echo "<table>";
    echo "<tr>";
           
    {
    
    while (false !== ($file = @readdir($handle))) { 
    $bestand = $dir ."/". $file;
    $ext = pathinfo($bestand);
    if($ext['extension'] == $exten1 || $ext['extension'] == $exten2 || $ext['extension'] == $exten3)
    
    while($row = mysql_fetch_array($result)) {
    
    {
      
    $width = getimagesize($bestand);
    if($width[0]<$maxwidth)
    
    {
    
    /* 
    echo "<td align=\"center\">";
    echo "<a href=\"http://localhost/scripts/index.php?id=$row[$id]\"><img border=\"1\" src=\"images/$row[element_5]\" alt=\"$row[element_1]\" title=\"$row[element_1]\">";
    echo "<p />";
    echo "<a href=\"$row[element_2]\">$row[element_1]</a>";
    */
    
    }

    else

    {
    
    echo "<td align=\"center\">";
    echo "<img src=\"images/$row[element_5]\" border=\"1\" width='$maxwidth' alt=\"$row[element_1]\" title=\"$row[element_1]\">";
    echo "<p />";
    echo "<a href=\"$row[element_2]\">$row[element_1]</a>";
    

    } 
    }
    } 
    }
    @closedir($handle);
    } 
    
    echo "</tr>";
    echo "</td>";
    echo "</table>";
    
                             // End Resize Image To Specific Dimensions Code //

?>











<p />
&nbsp;
<p />

<div align="center">

<?=$pagination?></div>

</body>
</html>
Thank you
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-13-2009, 08:56 AM Re: Simple table tags problem
Novice Talker

Posts: 5
Name: losangelescarrental
Trades: 0
for "<table><tr>", must have "<td>".
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
losangelescar is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Simple table tags 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 1.03801 seconds with 13 queries