danmaxito Posted March 15, 2006 Share Posted March 15, 2006 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 Quote Link to comment Share on other sites More sharing options...
ober Posted March 15, 2006 Share Posted March 15, 2006 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. Quote Link to comment Share on other sites More sharing options...
danmaxito Posted March 16, 2006 Author Share Posted March 16, 2006 Thank You [b]VERY[/b] Much. Everything works like a charm :) Quote Link to comment Share on other sites More sharing options...
danmaxito Posted March 18, 2006 Author Share Posted March 18, 2006 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 Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted March 19, 2006 Share Posted March 19, 2006 which ever column you are going to display use the substr function. Quote Link to comment Share on other sites More sharing options...
danmaxito Posted March 19, 2006 Author Share Posted March 19, 2006 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!!!! Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted March 19, 2006 Share Posted March 19, 2006 I'm not sure what you really mean, but I think you mean[code]$deleteid = $_GET["deleteid"];[/code] Quote Link to comment Share on other sites More sharing options...
danmaxito Posted March 19, 2006 Author Share Posted March 19, 2006 Um... will it help if I let you see the site? Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted March 19, 2006 Share Posted March 19, 2006 Yea, were you talking about when you click "delete" or w/e and then it sends you to an empty page? Quote Link to comment Share on other sites More sharing options...
danmaxito Posted March 19, 2006 Author Share Posted March 19, 2006 [a href=\"http://www.lancasterpaintingco.com/admin/articles/index.php\" target=\"_blank\"]Here is the link[/a] The login info is : demo/demoyou 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) Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted March 19, 2006 Share Posted March 19, 2006 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. Quote Link to comment Share on other sites More sharing options...
danmaxito Posted March 19, 2006 Author Share Posted March 19, 2006 Here is the catdetail.php file [code] taken out[/code] Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted March 19, 2006 Share Posted March 19, 2006 [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. Quote Link to comment Share on other sites More sharing options...
danmaxito Posted March 19, 2006 Author Share Posted March 19, 2006 This is where I am having the problem... any suggestionsPS: Yes, I coded this. It's a project I have for a church. Thanks Quote Link to comment Share on other sites More sharing options...
danmaxito Posted March 19, 2006 Author Share Posted March 19, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.