www.webdeveloper.com
Results 1 to 2 of 2

Thread: Need help displaying content based on date

Hybrid View

  1. #1
    Join Date
    Mar 2011
    Posts
    67

    Need help displaying content based on date

    I need assistance with my effort in trying to query and then display information from a database. Here is what I am trying to accomplish:

    2013-03-03
    Piece of software updated on this date
    Updated software
    more example of software
    software

    2011-03-18
    A piece of software
    This piece of software
    Something else

    2011-07-20
    Here is some software
    A new piece of software

    As you can see I am trying to result the display in showing the date of release and then if any software was updated on that date, to list any software with that release date.

    In my database, I have the following structure:

    id
    name
    version
    link
    description
    dateadded
    category

    Here is my code as I have it now. I have tried various while loops or if...then loops and I can't seem to figure this one out. Any help is greatly appreciated.



    Code:
    $dbc=mysql_connect ($db_hostname, $db_username, $db_pass, $db_name) or die ('I am unable to connect to the database because of: ' . mysql_error());
    			mysql_select_db("tuxandp1_linux", $dbc) or die ('I am unable to find that db.');
    
        			$query=("SELECT * FROM software ORDER BY dateadded DESC LIMIT 7");
    			    $result=mysql_query($query) or die('Sorry, could not get software at this time '.mysql_error());
    				while($row=mysql_fetch_array($result))  {
    
    					$id=trim($row['id']);
    					$name=trim($row['name']);
    					$version=trim($row['version']);
    					$link=trim($row['link']);
    					$description=trim($row['description']);
    					$dateadded=trim($row['dateadded']);
    					$category=trim($row['category']);
    						echo"$dateadded";
    						echo "<div id=\"newestsoftware\" class=\"font\">";
        					echo trim("<a href=\"pages/singlesoftwarepiece.inc.php?id=$id&name=$name
        					&version=$version&url=$link&description=$description&dateadded=$dateadded
        					&category=$category\"/>$name</a>" . "<br>");
    						echo "</div>";
    			}
    					    echo "<br>";

    thanks,
    Randy

  2. #2
    Join Date
    Feb 2012
    Location
    youTUBE
    Posts
    234
    Use $row = mssql_fetch_assoc($result) rather than
    $row=mysql_fetch_array($result)
    Knowledge is that which can be shown to be the case, and Intelligence is the method one uses to deploy the demonstration of what is the case, everything else is Information.

    For a stronger Text reading try:
    http://www.wyc3.com/diction.php

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles