Jump to content

parodys

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

parodys's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. rofl ! TRICKS !! thank you so much !!! Lots of respect to both of you!
  2. wow thanks for the quick replies ! Ive done what you both suggested and i get an error.
  3. Hi there, A quick question, i have a simple article website I'm putting together. My database is set up like this; # articles id, title, article, created_at, catid # category catid, catname Ive passed a catid through links as below : <?php $query = "SELECT catname, catid FROM category"; $result = mysql_query($query) or die(mysql_error()); // make the catogories list and then passes the values on to archive page $entry = '<ol>'; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { list($catname, $catid) = $row; $entry .= "<li><a href=\"?view=archive&catid=" . $catid . "\">$catname</a></li>\r\n"; } $entry .= '</ol>'; // show the categories list echo $entry; ?> now it passes " http://localhost/codedad/?view=archive&catid=1 " on to the archive page. my problem is getting the archive page to display only the articles under the catid=1. below is the function ive made to display the catitems : <?php function displaycatitems() { db_connect(); $catid = $_GET["catid"]; if(!isset($_GET['catid'])) { $query ="SELECT title, article FROM articles, category WHERE cat=category.catid=".$_GET['id']; $result = mysql_query($query) or die('Error : ' . mysql_error()); while($row = mysql_fetch_array($result)) { echo $row['title']. " - ". $row['article']; echo "<br />"; } } else { echo "No Articles"; } } ?> I know this is more than likely starting me in the face but for the last 3 hours ive been trying to get this to work to no avail! Any help would be appreciated.
  4. i was looking for the same thing... check this out http://nettuts.com/tutorials/php/how-to-paginate-data-with-php/
  5. ok so ive made some progress, im not sure if ive done this the optium way, but its getting there slowly! <?php // displays catogories and makes a list with links to archive page db_connect(); $query = "SELECT catname FROM category"; $result = mysql_query($query) or die(mysql_error()); // make the catogories list $entry = '<ul>'; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { list($catname) = $row; $entry .= "<li><a href=\"$catname\">$catname</a></li>\r\n"; } $entry .= '</ul>'; // show the catogories list echo $entry ?> It lists the catogories now all i have to do is figure how to pass the the cat id along thanks for your help so far !
  6. haha yeah good point ive made the changes to the database and have been thinking about it. If i do a query for the categories to be listed in an unordered list, with links that will pass the value of the category to the archive page and in turn will it list the articles under that category ? maybe using a $_get ? and isset ? haha am i on the right track ?
  7. ok haha ive looked it up. I created a new table table name : cat id, cat i joined them but when i query it i get a list of all the articles cats.. php php php php and so on. $query = "SELECT articles.cat, cat.cat FROM articles, cat WHERE articles.cat = cat.cat"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['cat']; } hmmm
  8. yeah i have created a basic layout demo, thats what ive been working off. Just having trouble creating a menu for all the categories under cat from my database. In the database i have over 200 pages listed under 8 categories. so i need the menu to go like this. The trouble im having is making the actual menu from the CAT table in the database and then forwarding it to the archive page (paginated of cause) where it will list all the articles under the cat and once clicked on will go again to the actual article page. it probably simple stuff i just cant seem to get my head around it.
  9. Hey guys, I kinda new to PHP and mySQL, ive mastered HTML ( big woop eh ) now its time to get into proper coding etc and so ive been pointed to this forum to get some help! Here goes, i have a database that has table such as this : id, title, article, cat, created_at what i am trying to do is make a menu on the left side of my webpage, that will have a make a list of the all the cat, and once clicked will go to a page that lists all the articles under that cat. Would it be easier to create a relational database to correspond with the cat ? or make a function that will scan the cat table and out put a list of single cats? Im not sure if ive gone about this the right way, but ive made the structure like this. index.php <?php include('dbfuncs.php'); $controller = 'articles'; $view = empty($_GET['view']) ? 'index' : $_GET['view']; switch ($view) { case "index": $layout = 'home'; break; case "article": $layout = 'articles'; break; case "archive": echo "this is the archive page"; break; case "new": echo "this is the NEW page"; break; } if(isset($layout)) { include ($_SERVER['DOCUMENT_ROOT'].'/codedad/views/layouts/'.$layout.'.php'); } else { include ($_SERVER['DOCUMENT_ROOT'].'/codedad/views/layouts/'.$controller.'.php'); } ?> which is pretty much my templating system and web site layout. So if i type in wxw.codedad.com/?view=article it will take me to the the article page... and in that template ill have calls to functions that will display the data. It works well so far. but yeah im have trouble creating a menu for the cats. Obviously i have a lot of learning to do.. haha Any ideas or linkage to some info would be oh so appreciated !!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.