Jump to content

jabbamonkey

Members
  • Posts

    8
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

jabbamonkey's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am a newb to programming, and have been able to put together a fully functional PHP/MySQL site. I feel I did a good job at it. However, I want to take it to the next level. When a user goes to a page, the page pulls content from the database (based on the query that I set for that specific page). This worked fine, but I have to create EVERY page/folder that is linked to, and this isn't very efficient or user friendly. (even when using includes) Example of folder structure It might be best to show an example. Below is a website structure, where a ton of pages exists. Each page has a query relating to the information that it wants to pull from the database (Food, will pull ALL the food in the table; Apples, will only pull all the APPLE TYPES; and Red-Delicious will be a description page, containing only information relating to that specific row for Red Delicious Apples.) /Foods/ /Foods/Fruits/ /Foods/Fruits/Apples/ /Foods/Fruits/Apples/Red-Delicious What I do now... As I have it now, I have to create a page and folder for EACH of these sections, and that is ALOT of work. /Foods/index.php /Foods/Fruits/index.php /Foods/Fruits/Apples/index.php /Foods/Fruits/Apples/Red-Delicious/index.php And, if there is an issue on one page, then I need to go through ALL the pages and make the revision. And, if the database categories change, then the entire folder structure that I use is messed up and has to be redone (with all the links)... What I need to do... I wanted to know if there was some way to use a master page (Foods/index.php) and have it used as a base for all the other pages/folders. And, maybe doing something with htaccess to point to those folders. So, the htaccess may be something like... (below is what I want to do, and certainly not the code I would use... since I don't know how to do this) Redirect Foods/index.php?Cat1=Fruits Foods/Fruits/ Redirect Foods/index.php?Cat1=Fruits&Cat2=Apples Foods/Fruits/Apples Redirect Foods/index.php?Items=Red-Delicious Foods/Fruits/Apples/Red-Delicious Real life example: https://www.dnd-spells.com/spells/ When you click on an individual spell, it goes to the individual spell page... https://www.dnd-spells.com/spell/aganazzars-scorcher The individual page is NOT a page that the author created. With over 400 spells, I'm pretty sure the server somehow redirects the URL to a template page. In Closing Once again, I am new to programming and not very proficient with server-lingo. So, if you can point me to a tutorial, or tell me what I may need to ask my webhost, that would be VERY helpful. Or, try and use small words so I understand. 😁 Let me know if you can help. Thanks.
  2. I have the action going to the confirm page (every form I have, has it\'s own confirm page) action=\"survey_confirm.php\" Not sure what you mean by: $data = $_POST[\'data\']; Where would this go, and what would this do? Jabbamonkey
  3. I have a form that is trying to upload the information into the MySQL satabase. BUT, for some reason the new rows aren\'t being added, and I am not getting any error message. I have similar forms that enter information into other tables just fine, but this one is not working... Can someone tell me the best way to trouble shoot this? As the information isn\'t actually getting submitted in the table, is there some way I can have an error message appear telling me what\'s wrong? Here is the code below.... $db = mysql_connect($host, $user, $pass); mysql_select_db($dbname,$db); $sql = mysql_query(" INSERT INTO survey_readerstudy (howold, havepark, fampark, email_address) VALUES (\'$howold\', \'$havepark\', \'$fampark\', \'$email_address\')",$db); Please help!!!
  4. I have a list of items, and I want to choose one randomly to appear on the page. Is there a simple way, while writing a query, to choose 1 random row from a table? If so, can someone tell me how? I know I can do it using the following steps, but want to know if there is a shortcut, simply doing it within the query ... 1) Count rows in a table (lets say the number of rows is 234) 2) Choose a random number ($rand_row is a number between 1 and 234) 3) Now, perform a query with \"... LIMIT $rand_row, 1 ...\"
  5. After I set my query; here\'s what I have.... $result2 = mysql_query($query1,$db); $num_results = mysql_num_rows($result2); if($num_results!=0) { do { // PRINT INFORMATION FROM DATABASE } while ($myrow2 = mysql_fetch_array($result2)); }
  6. I keep getting an error ... Does it matter the order of the WHERE clause? For example, does it matter if \"b.article_id=c.article_id\" or \"c.article_id=b.article_id\"? SELECT a.comment_id, a.name, a.email, a.comment, a.live, b.article_name, c.article_id, c.comment_id, c.commentjuke_id FROM comments as a, articles as b, connect_commentarticles as c WHERE b.article_id=\'$id\' AND c.article_id=b.article_id AND a.comment_id=c.comment_id AND a.live=\'1\'";
  7. Would this be right? SELECT a.comment_id, a.name, a.email, a.comment, a.live, b.article_name, b.article_id, c.article_id, c.comment_id, c.commentjuke_id FROM comments as a, articles as b, connect_commentarticles as c WHERE b.article_id=\'$id\' AND c.article_id=b.article_id AND a.comment_id=c.comment_id AND a.live=\'1\'";
  8. I have three tables I\'m trying to combine. Two tables have information regarding a subject, and the third table is what I call the \"Connection\" table. I have the following query.... SELECT a.comment_id, a.name, a.email, a.comment, a.live, b.article_name, b.article_id, c.article_id, c.comment_id, c.commentjuke_id FROM comments as a, articles as b, connect_commentarticles as c WHERE c.article_id=\'$id\' AND a.comment_id=c.comment_id AND a.live=\'1\'"; Basically, Comments for articles are stored in one table. Articles content is stored in the other, and the third table pulls the two tables together (only three columns, for the article id, the comments id, and it\'s own id). I just want to pull the tables together but keep getting an error. NOTE: the variable \"$id\" is the article id, that will be submitted by the user. Please let me know if you can help!
×
×
  • 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.