Author Topic: What is the proper way?  (Read 18915 times)

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
What is the proper way?
« on: July 11, 2008, 09:29:07 PM »
I have a need to output the table data to the website after a search, no biggy. The website is coded in html/php using div's and i am going to need to output into a set area and have it scroll to accomodate result size.

After alot of reading it seems you will be told tables is wrong use div, or visa versa. What do you guys think is the best way to approach it?

Here is an example of the raw output: NOTE this is on the swinger domain so caution if at work. Just text.

Clicky

Attached is the html file im displaying it in with an example of how it would look. Minor images on it, no biggy.
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: What is the proper way?
« Reply #1 on: July 11, 2008, 09:30:45 PM »
tables for tabular data

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: What is the proper way?
« Reply #2 on: July 11, 2008, 09:42:55 PM »
Going tables means i will most likely have to re-do the page its being used on which is why i wanted another opinion before i went that route. Honestly i think that is probably easier then trying to get it to work the way i want in a div setup
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: What is the proper way?
« Reply #3 on: July 12, 2008, 01:38:02 PM »
Not sure how you'd do tabular data in a div... that just seems messy.

Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: What is the proper way?
« Reply #4 on: July 12, 2008, 02:00:03 PM »
Another possible way is to use a dl.  That is useful for things like displaying addresses where you could display it tabular but it makes more sense in another format.

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: What is the proper way?
« Reply #5 on: July 12, 2008, 02:00:41 PM »
they certainly do it. For the most part its basically

<div settings>
<?
php code to output data
?>
</div>

hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: What is the proper way?
« Reply #6 on: July 12, 2008, 02:01:13 PM »
Another possible way is to use a dl.  That is useful for things like displaying addresses where you could display it tabular but it makes more sense in another format.

What im outputting is details of an event, including a description. Would this be a better option?
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: What is the proper way?
« Reply #7 on: July 12, 2008, 02:03:42 PM »
It could be.  You could do something like:

Code: [Select]
<dl>
<dt>Title of 1st event</dt>
<dd>Description</dd>
<dd>Address</dd>

<dt>Title of 2nd event</dt>
<dd>Description</dd>
<dd>Address</dd>

</dl>

Would probably look nicer then just dumping it out as a table.

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: What is the proper way?
« Reply #8 on: July 12, 2008, 02:06:21 PM »
Thats a good idea, ill try that out next time im working on it and see if i can get a nicer result. Thanks :)
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: What is the proper way?
« Reply #9 on: July 13, 2008, 01:48:03 PM »
I'm getting weird formatting with <dl>. I tried it with some basic html output too and its pretty much the same. How do you organize it for desired output?

Code: [Select]
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
    $field = mysql_fetch_field($result);
echo "<dl>";
    echo "<dt>{$field->name}</dt>";
echo "</dl>";
}
//echo "</dl>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
    //echo "<dl>";

    // $row is array... foreach( .. ) puts every element
    // of $row to $cell variable
    foreach($row as $cell)
echo "<dl>";
        echo "<dd>$cell</dd>";
echo "</dl>\n";


}
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: What is the proper way?
« Reply #10 on: July 13, 2008, 03:10:34 PM »
Dude seriously go look up dl, dt, and dd on the internet and see how they are used.

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: What is the proper way?
« Reply #11 on: July 13, 2008, 03:25:19 PM »
I did, actually at this site (http://www.htmlcodetutorial.com/_DL.html) but even looking at that i dont know if it will work because i need the titles going across the top and the data across under it so a list may not work right
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: What is the proper way?
« Reply #12 on: July 13, 2008, 03:27:03 PM »
i may have to output it in a table and use a div to control it....ugh
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: What is the proper way?
« Reply #13 on: July 13, 2008, 05:17:41 PM »
This is how I would do it personally:
Assuming the following table columns:
title = title of the event
desc = description of the event
streetaddy = street address
city = uh city
state = do I really need to say
zip = yeah if you don't get it by now....

Code: [Select]
<?php
$result 
mysql_query('
SELECT title, `desc`, streetaddy, city, state, zip
FROM events'
);

if (!
$result)
die('Oh fuck');

if (
mysql_num_rows($result) == 0)
{
echo '<div>No events</div>';
return;
}

echo 
'
<dl>'
;

while (
$event mysql_fetch_assoc($result))
{
echo '
<dt>'
$event['title'], '</dt>
<dd class="description">'
$event['desc'], '</dd>
<dd class="location">
'
$event['streetaddy'], '
'
$event['city'], ', '$event['state'], ' '$event['zip'], '
</dd>'
;
}

echo 
'
</dl>'
;

mysql_free_result($result);
?>

Then use CSS to make it look pretty (like using pre formating on the address)

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: What is the proper way?
« Reply #14 on: July 13, 2008, 05:19:28 PM »
Thanks mike thats really helpful. It wouldnt be so bad if they had of done this project better from jump street. Plus i never had to make table output pretty before. Appreciate the example :)
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?