Jump to content


Photo

Please help


  • Please log in to reply
14 replies to this topic

#1 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 15 March 2006 - 06:13 PM

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

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 15 March 2006 - 06:16 PM

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:
$query = "SELECT * FROM Articles WHERE Category_ID = '" . $_REQUEST['catid'] . "'";

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

Hope that helps.

Info: PHP Manual


#3 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 16 March 2006 - 03:30 PM

Thank You VERY Much. Everything works like a charm :)

#4 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 18 March 2006 - 11:58 PM

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

#5 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 19 March 2006 - 12:07 AM

which ever column you are going to display use the substr function.
follow me on twitter @PHPsycho

#6 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 19 March 2006 - 02:01 AM

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!!!!

#7 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 19 March 2006 - 02:29 AM

I'm not sure what you really mean, but I think you mean

$deleteid = $_GET["deleteid"];


#8 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 19 March 2006 - 02:40 AM

Um... will it help if I let you see the site?

#9 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 19 March 2006 - 02:42 AM

Yea, were you talking about when you click "delete" or w/e and then it sends you to an empty page?

#10 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 19 March 2006 - 02:52 AM

[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)

#11 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 19 March 2006 - 03:07 AM

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]?art_Id=. 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.

#12 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 19 March 2006 - 03:12 AM

Here is the catdetail.php file
taken out



#13 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 19 March 2006 - 03:18 AM

          <td><a href="/admin/articles/viewart.php?art_Id=<?php echo $row_rsdetcat['art_Id']; ?>" >View</a></td>
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.

#14 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 19 March 2006 - 03:39 AM

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



#15 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 19 March 2006 - 04:01 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users