Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member Tonic's Avatar
    Join Date
    Jan 2004
    Posts
    25
    Member #
    4684
    Hi! I've currently developed a news management system for my sites...

    The question is, how would I go about have custom images pertaining categories of news on my system?

    Here is the code to retrieve the information from the database, and printing it to the block of news:

    Code:
    $query  = "SELECT * FROM news ORDER BY news_date DESC";
    $result = mysql_query($query);
    
    while($row = mysql_fetch_assoc($result))
    {
        echo "<div style='border: 1px solid rgb(170, 170, 170); padding: 10px; margin-bottom: 10px; clear: both;'>
    <div style='margin: 5px; padding: 5px; float: right;'>
    <img src='images/gen.png' style='border: 0pt none ;'>
    </div><div class='topictitle'> 
    	 " . "{$row['news_title']} </div><div class='postdetails'>" .
             "{$row['news_date']} by <font color='#659D32'>" .
             "{$row['news_user']} </font><font color='#FFFFFF'>" .
             "{$row['news_id']} </font></div><hr><div class='postbody'>" .
             "{$row['news_body']} </div><br></div>";
    }
    right now, it's displaying the static image of "gen.png" with the code:

    Code:
    <img src='images/gen.png' style='border: 0pt none ;'>
    What I want is, to display the image of that category, which is stored onto my database.

    In my table, I have a column labeled "news_cat" which I than store information like:
    gen, ex1, ex2, ex3 and so on.

    So when I insert a news article, I have a drop down menu with different categories, which insert the category name to the database...

    Now I need to retrieve that data and display it with dynamic code in place of the "gen.png"

    So... I'd need to do something like this:
    $gen = gen.gof
    $ex1 = ex1.gif ect ect... Any suggestions? Or perhaps a better way on displaying a category image... I've tried to implement this AFTER I create my database and news system, so I think it might be a bit more difficult situation.. but I'd like to hear other's opinions

    Thanks!

  2.  

  3. #2
    Junior Member Tonic's Avatar
    Join Date
    Jan 2004
    Posts
    25
    Member #
    4684
    Oooops, I answered my own question sorry.

    All I had to do was retrieve the category name (which is like gen.gif) and post that after the tag, so it looked like this

    Code:
        echo "<div style='border: 1px solid rgb(170, 170, 170); padding: 10px; margin-bottom: 10px; clear: both;'>
    <div style='margin: 5px; padding: 5px; float: right;'>
    <img src='images/". "{$row['news_cat']}' style='border: 0pt none ;'>
    :P

    But still open for suggestions on better implementation!! Thanks.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:15 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com