Jump to content

Archived

This topic is now archived and is closed to further replies.

danmaxito

Please help

Recommended Posts

Hello everyone. I have been checking this site out a lot, and decided to join the forum team.

I am running into a problem that I hope I can explain correctly.

Here goes:

I have 2 tables ("Articles" and "Categories"). On the index.php page I display all the categories (which can be "Edited", and "Deleted"). The categories are linkable, and once you link on one, it will show you all the articles that are listed under that category (and each article can be "Edited" and "Deleted").

Once I click on a category from the index page, the category ID is passed on the URL, but I do not know how to tell PHP to only show the artciles in that category....

I am also VERY open to suggestions on other was of completing this small project.


THANKS A MILLION IN ADVANCE.

Danmaxito

Share this post


Link to post
Share on other sites
I'm going to assume a few things:

1) That you're storing the Category ID in the Articles Table with each article.
2) You're already using SELECT SQL statements to grab the data.

If those 2 things are correct, all you need to do is know how to use a WHERE clause in your SQL statement:
[code]$query = "SELECT * FROM Articles WHERE Category_ID = '" . $_REQUEST['catid'] . "'";[/code]

Then you just run the query and display the results as you normally would.

Hope that helps.

Share this post


Link to post
Share on other sites
I have another question if I may...
Using the same page, I want to only show 20 characters (Letters) from one of the DB columns.
How do I do that using PHP.

Thanks

Share this post


Link to post
Share on other sites
which ever column you are going to display use the substr function.

Share this post


Link to post
Share on other sites
thanks..It is working now.

I am really confused (lost).
Once the admin click on a category, all the articles within that category are listed on a new page. By each article I have "edit","Delete" buttons. I used the code that Ober gave me... and I got that to work. But when the new page loads displaying all the articles in the category that the admin clicked on, I can't get the buttons by each category to work right. It just loads a blank screen, and does not pass the articles ID. How can I get this to work.

I really appreciate the help that you guys are giving me!!!!

Share this post


Link to post
Share on other sites
[a href=\"http://www.lancasterpaintingco.com/admin/articles/index.php\" target=\"_blank\"]Here is the link[/a]

The login info is : demo/demo

you will first be taken to a login page... then after you login, you will be redirected to the article page. You will see a list of categories for a church. Click on the "prayer" category (click on the word). Then you will see a new page with all the articles under that category. Next to each article are the modification buttons. I disabled all of them except for "View" which will open up a new page (suppose to grab the ID of the article clicked on) and show anything within that article.

Does this make sense?

I basically need to know how to pass the ID of the article to the Modification page (Edit, Delete, view, etc)

Share this post


Link to post
Share on other sites
Well first, does all articles have an ID of some sort?

I noticed it goes to [a href=\"http://www.lancasterpaintingco.com/admin/articles/viewart.php\" target=\"_blank\"]http://www.lancasterpaintingco.com/admin/a...les/viewart.php[/a][b]?art_Id=[/b]. After the art_Id= should be the article ID you want to be looking at.

Can I please see the source of [a href=\"http://www.lancasterpaintingco.com/admin/articles/viewart.php?art_Id=\" target=\"_blank\"]http://www.lancasterpaintingco.com/admin/a...art.php?art_Id=[/a] and [a href=\"http://www.lancasterpaintingco.com/admin/articles/catdetail.php?cat_Id=1\" target=\"_blank\"]http://www.lancasterpaintingco.com/admin/a...il.php?cat_Id=1[/a] ? I don't know where you are in the script right now.

Share this post


Link to post
Share on other sites
[code]
          <td><a href="/admin/articles/viewart.php?art_Id=<?php echo $row_rsdetcat['art_Id']; ?>" >View</a></td>[/code] in catdetails.php is where the article is being passed to viewart.php. Make sure there is a field in your MySQL table named "art_Id" and with the proper information.


P.S. Did you code this by yourself? I am very impressed! Not to mention that my family is a very religous one.

Share this post


Link to post
Share on other sites
This is where I am having the problem... any suggestions

PS: Yes, I coded this. It's a project I have for a church. Thanks

Share this post


Link to post
Share on other sites
I figured it out.... I needed to add the art_Id to all the rows as a hidden field. then it would get passed. Thanks soooo much :)

PS: I also changed the recordset that the "View" link was calling from

Share this post


Link to post
Share on other sites

×

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.