Jump to content

Get category name.....


Skarabeol

Recommended Posts

Here is posts.php

<?php include('includes/functions.php'); ?>
<html>
<head>
<title>Basic CMS- Admin Area</title>
</head>
<body>
<a href="logout.php">Logout</a>
<a href="posts.php">Manage Posts</a>
<table cellspacing="0" cellpadding="10">
<thead>
<tr>
	<td>Post Title</td>
	<td>Author</td>
	<td>Category</td>
	<td>Action</td>
</tr>
</thead>
<tbody>
<?php getPosts(); ?>
</tbody>
</table>

</body>
</html>

 

Here is a part of functions.php

<?php
include('includes/connect.php');

function getPosts() {
$query = mysql_query("SELECT * FROM posts") or die(mysql_error());
if(mysql_num_rows($query) == 0) {
		echo "<tr><td colspan=\"3\">No Posts Where found</td></tr>";
} else {
		while($post = mysql_fetch_assoc($query)) {
		echo "<tr><td>" . $post['Title'] . "</td><td>" . $post['Author'] . "</td><td>" . $post['category_id'] . "</td><td><a href=\"delete.php?id=" . $post['ID'] . "\">Delete</a><br /><a href=\"edit.php?id=" . $post['ID'] . "\">Edit</a></td></tr>";
	}
}
}

 

 

Table posts

ID

Title

Author

Content

category_id

 

Table categories

IDNameDescription

 

 

 

When i access posts.php it shows me that:

categoryproblem.png

 

 

I want to display me there the name of category wich has the ID = with category_id from posts table :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.