SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Database content not displaying???

    Can someone please have a look at my code that is below and tell me why the database content isn't displaying? I can't seem to work out why the content isn't displaying. Thanks in advance.

    Code PHP:
      require "config.php";
      // display the home page and calendar links
      echo "\n<tr><td width=\"15%\" valign=\"top\">\n";
      echo "<div class=\"box1\"><center>";
      echo "<div class=\"maintxt\"><a href=view_edit_delete.php?page=Home>HOME</a></div>";
      echo "</center><br />\n";
      echo "<div class=\"padding\"><a href=\"calendar.php\" id=\"link\"><div class=\"maintxt\">CALENDAR OF EVENTS</div></a></div></div>\n";
      echo "</td>\n";
     
      $query = ("SELECT * FROM pages") or die ("Could not query because: ".mysql_error());
      while ($row = mysql_fetch_array($query)) {
      $pagetitle = str_replace('%20', ' ', $row['page_title']);
      $pagetitle2 = strtoupper($pagetitle);
      //if ($row['page_title'] != 'Home') {
      	echo "<td width=\"15%\" valign=\"top\">\n";
      	echo "<div class=\"box1\"><div class=\"heading\"><center><div class=\"maintxt\">".$pagetitle2."</div></center></div></div>";
    	echo "</td>\n";
      	//echo "<td width=\"15%\" valign=\"top\">\n";
    	//echo "<div class=\"box1\"><div class=\"heading\"><center><div class=\"maintxt\"><a href=view_edit_delete.php?page=".$row['page_title'].">".$pagetitle."</a></div></center></div></div>\n";
    	//echo "</td>\n";
      //}
      }
      // resources link
      echo "<td width=\"15%\" valign=\"top\"><div class=\"box1\"><div class=\"heading\"><center><div class=\"maintxt\"><a href=\"resources.php\">RESOURCES</a></div></center></div></div></td></tr>\n";
      // member's login link
      echo "<tr><td valign=\"top\">&nbsp;</td>";
      echo "<td valign=\"top\">&nbsp;</td>";  
      echo "<td valign=\"top\"><div class=\"box1\"><div class=\"heading\"><center><div class=\"maintxt\"><a href=\"memberslogin.php\">MEMBER'S LOGIN</a></div></center></div></div></td>\n";
      // add a page link
      echo "<td valign=\"top\"><div class=\"box1\"><div class=\"heading\"><center><div class=\"maintxt\"><a href=\"add_page.php\">ADD A PAGE</a></div></center></div></div></td>\n";
      echo "<td valign=\"top\">&nbsp;</td></tr>";
      mysql_close();

  2. #2
    SitePoint Enthusiast lkagan's Avatar
    Join Date
    Sep 2007
    Location
    Boca Raton, Florida
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're missing a step. You build the result set like this (taken directly from the php.net site):

    PHP Code:

    mysql_connect
    ("localhost""mysql_user""mysql_password") or
        die(
    "Could not connect: " mysql_error());
    mysql_select_db("mydb");

    $result mysql_query("SELECT id, name FROM mytable");

    while (
    $row mysql_fetch_array($resultMYSQL_NUM)) {
        
    printf("ID: %s  Name: %s"$row[0], $row[1]); 
    }

    mysql_free_result($result);
    ?> 
    Larry Kagan
    Lead Web Application Developer
    Superiocity, Inc.


Bookmarks

Posting Permissions

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