1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Displaying PHP results in a table

Discussion in 'PHP' started by carowan, Mar 21, 2005.

  1. #1
    Im giving PHP my first whirl, and have been working on a script that I found to display the 4 most recent forum topics. I would like to put each result into a cell of a 2x2 table but don't know how.

    Can someone give me a general idea of where to start?


    Thanks.
     
    carowan, Mar 21, 2005 IP
  2. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #2
    
    
    echo '<table><tr><td align="right">' . 
    $var1 . 
    '</td><td align="left">' .
    $var1desc .
    '</td></tr><tr><td align="right">' .
    $var2 .
    '</td><td align="left">' .
    $var2desc .
    '</td></tr></table>';
    
    PHP:
    There's one way.
     
    noppid, Mar 21, 2005 IP
    carowan likes this.
  3. carowan

    carowan Peon

    Messages:
    473
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks!
    I'll give it a shot.
     
    carowan, Mar 21, 2005 IP
  4. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    There is a better thing to do. Just search for "phplib" in google and u will get a library set which inlcuded virtually everything u need to code.

    the database connections are made as simple like this,
    $db = new DB();
    $db->query(query string); etc.

    and there is a table class too, which allows you to creat tables by just calling a function with certain arguments. also it can create a table from an sql query result set.

    then if u wish to create a template based site there are funsctions for this too.

    if u think seriously of php, phplib is not the thing u wish to forget.

    I am not in anyway related to phplib's development, i am just a very much satisfied downloader. i guarentee you, you can save half time u spend on coding from now on if u spend one hr to read and experiment the different classes and functions available.
     
    king_cobra, Mar 21, 2005 IP
  5. Juls

    Juls Well-Known Member

    Messages:
    1,867
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    170
    #5
    i agree phplib is pretty good until you are good enough to code your own class / functions. :)

    good way to get into php.
     
    Juls, Mar 21, 2005 IP
  6. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #6
    While I agree that this is probably good. We do have a new programmer here. I wonder if classes are really the direction to go? I believe that he should know what the functions in the class do. ie. Know html and how to create a 2 row 2 column table. :/
     
    noppid, Mar 21, 2005 IP
  7. nullbit

    nullbit Peon

    Messages:
    489
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Carawan, you should probably try nail this for sake of experience, but once you pass the beginner stage you need to try separate application code from presentation code entirely (using the smarty engine for example).
     
    nullbit, Mar 21, 2005 IP
  8. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I am not saying that he must not go for basic php than to jump to classes. But as the phplib guys say u need not be an expert to code with phplib. You can code if u know the basic syntax of php. Also the built in classes (no need to worry hearing the word class) are so well documented that u can find what u r looking for in matter of seconds. You just think of some functions wih which u can get a thing done and the function will b there.

    You can ask me for any help regarding phplib.
     
    king_cobra, Mar 22, 2005 IP
  9. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #9
    Yeah I guess ya have a point, learning the classes right off could be an advantage.
     
    noppid, Mar 22, 2005 IP
  10. carowan

    carowan Peon

    Messages:
    473
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thank you everyone for your input!

    I have gotten noppid's suggestion to work, so will use this for now, and crack open the PHP bible to learn more about classes when I start becoming more proficient.

    King Cobra and Nulbit, I did take a look at both Smarty and PHPlib, both of which I was not aware of. Excellent resources
     
    carowan, Mar 22, 2005 IP