Jump to content

jstgermain

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jstgermain's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. nvm everyone.  got it working.  got help from a friend.  here is the code in case anyone else is ever needing to do something similar [code] <?php #menu.php $sql = "SELECT * FROM `Menu`";  $result = mysql_query($sql);  while ($row = mysql_fetch_assoc($result)) {     $id = $row['id']; // get the row id     $link[$id]['name']      = $row['name']; // put in an array     $link[$id]['l_name']    = $row['l_name']; // put in an array     $link[$id]['content']  = $row['content']; // put in an array } ?> <!--// Links code //--> <a href="index.php?page=<?php echo $link['1']['l_name']; ?>"><?php echo $link['1']['name']; ?></a> <a href="index.php?page=<?php echo $link['2']['l_name']; ?>"><?php echo $link['2']['name']; ?></a> <a href="index.php?page=<?php echo $link['3']['l_name']; ?>"><?php echo $link['3']['name']; ?></a> [/code] Just add as many links as needed.
  2. sorry to bump this, but it is at the bottom of the second page now, and i still need help if possible.  please le tme know if anyone else can figure this out.
  3. no, didnt work.  just displays the first 3 letters od the first row in the link name.  :S  the link name and name of the riste row is "Home", so the first like shoed up as "H", link two showed as"o", and link 3 showed as "m".  :S  so, the wuery itself looks ok, but the way you are calling the link with the [[b]0[/b]], [[b]1[/b]], and [[b]2[/b]] isnt correct.  need another way to tell it the row.  let me know if you think of something else.  thanks
  4. that might, i will try it in a bit.  need to finish this asp / js project at work first.  i will let you know if it works or not.  i am sure it will, but for some reason i just couldnt think of it.  :p  head hurts with all these projects.  :S  thanks.
  5. ok, i will provide a few things so that someone may be able to help with what i am trying to do.  here is my MySQL setup for the table that contains the info that I am trying to retrieve. -- -- Table structure for table `Menu` -- CREATE TABLE `Menu` (   `id` int(25) NOT NULL auto_increment,   `name` varchar(100) default NULL,   `l_name` varchar(100) default NULL,   `content` text,   PRIMARY KEY  (`id`) ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; -- -- Dumping data for table `Menu` -- INSERT INTO `Menu` VALUES (1, 'Home', 'Home', 'Home page info here.); INSERT INTO `Menu` VALUES (2, 'Hosting', 'Hosting', 'Put hosting info here'); INSERT INTO `Menu` VALUES (3, 'Contact Us', 'ContactUs', 'Put contact info here'); here is the php i am currently using. [code] <?php #menu.php //Link 1 query $query1 = "SELECT * FROM Menu WHERE id=1"; $link1 =  mysql_query ($query1); $l1 = mysql_fetch_array ($link1, MYSQL_ASSOC); //Link 2 query $query2 = "SELECT * FROM Menu WHERE id=2"; $link2 =  mysql_query ($query2); $l2 = mysql_fetch_array ($link2, MYSQL_ASSOC); //Link 3 query $query3 = "SELECT * FROM Menu WHERE id=3"; $link3 =  mysql_query ($query3); $l3 = mysql_fetch_array ($link3, MYSQL_ASSOC); ?> <!--// This is where I display the links //--> <a href="index.php?page=<?php echo $l1['l_name']; ?>"><?php echo $l1['name']; ?></a> <a href="index.php?page=<?php echo $l2['l_name']; ?>"><?php echo $l2['name']; ?></a> <a href="index.php?page=<?php echo $l3['l_name']; ?>"><?php echo $l3['name']; ?></a> [/code] as you can see, i am having to query the database 3 differnt times to make each link url and name display, and that is sort of a pain in the butt, and i am sure there is a better and easier way to do this.  hopefully someone can help me shorten this task.  keep in mind that there will be more than 3 links.  there are just 3 right now since i am still in the testing phase of everything.  any help will be greatly appreciated.  thanks in advance.
  6. ok, well, none of the code you guys tried to help with did anything.  the closest help came from magic2goodil, but left out that i still needed to query the database to get the results to echo the correct row, but i appreciat you guys and gals trying to help.  that is why i love this community.  even though i didnt get what i was looking for, i was still pointed in a good direction to figure it out myself. jesirose, as far as the sql injection, i am not sure exactly how that would happen with this site, but i will definately look into it and see if i can find some things to make it a little more secure.  thanks fo rthe advise.
  7. here is the problem, and hopefully somone will have a solution. i set my new site to have the menu be php and run on the mysql database, and obviously all the content too, but when i go to the home page, nothing displays as far as content since there is no link selected yet. how can i get it to automatically display the same info as the home link if no link has been clicked yet? here is a link to the site to see what i am talking about http://www.mct-hosting.com the content i want to display will be the same as: http://www.mct-hosting.com/index.php?page=Home here is a little code that might help. [code] <?php #This is in the index page $get =  mysql_query("SELECT * FROM `Menu` WHERE l_name='$_GET[page]'") OR DIE(mysql_error()); $page = mysql_fetch_assoc($get); //table settings are here, NOT IMPORTANT FOR THIS //code for displaying the content once a link is clicked echo $page['content']; ?> [/code] here is the code for the links that makes the content display [code] <?php $query1 = "SELECT * FROM Menu WHERE 1 AND id=1"; $link1 =  mysql_query ($query1); $l1 = mysql_fetch_array ($link1, MYSQL_ASSOC); echo '<a href="index.php?page='.$l1['l_name'];.'">'.$l1['name'];.'</a> ?> [/code] hopefully that helps with solving the problem.
  8. thanks again for the help.  i may try that in a bit, but right now, i just recoded the database to contain only one table for all the contente instead of seperate tables, and i have coded it to pull the corresponding info per the id and it works great.  so, i only had to code the check in once.  thanks for everything.  if you ever need graphics, let me know.
  9. your second example is perfect.  i put it in where the user would submit the changes, and it then checked if it was admin or not, and when i was in the demo account, it blocked me perfectly, and allowed access when i was in the admin account.  thanks so much for that.  looks like i was on the right path, but was just missing a few minor things that obviously amounted to be a big problem.  :P anyways, my last question would be, is it possible for me to make a file like i did with the process.php file and not have to type the code everytime i want to check the level?  the process.php file checks to see if i am logged in or not, and if not, it redirects me to log in, and would like to do something similar with the check for admin or demo. **EDIT** thought it might help if i provide the code [code] <?php //////////////////////////////////////////////////////////////////////////////////////////////// // Enerything in here                                                                        //                                                                                           // // Check to see if the user has access to make changes before changing, otherwise error  // $user = htmlspecialchars($_SESSION['user'], ENT_QUOTES);                                  // $check = mysql_query("SELECT `id` FROM `login` WHERE `user` = '$user' AND level = 1");    // if(mysql_num_rows($check) == 1) { // Make sure level is 1 for the user                    //                                                                                           // //////////////////////////////////////////////////////////////////////////////////////////////// // If the admin level check OK, then do the following $query="UPDATE Home SET content='$_POST[content]' WHERE id=1"; mysql_query($query); if (mysql_affected_rows() == 1) { // If it ran OK echo '<h1 id="mainhead">Thank you!</h1> <p class="main_txt">You have updated the information.</p> <p class="main_txt"><a href="admin.php">Back</a> to the Admin Home.</p>'; include('includes/admin_footer.php'); exit(); } //////////////////////////////////////////////////////////////////////////////////////////////// // and somehow this too                                                                      //                                                                                               // } else {  // Print and error is admin level is set to demo                                // Print 'Error: You do not have access.';                                              // include('includes/admin_footer.php');                                                    // exit();                                                                                  // } // End Admin level check                                                                //                                                                                               // //////////////////////////////////////////////////////////////////////////////////////////////// ?> [/code] i would like the parts that are inside of the /'s to be in the seperate file somehow.  is this possible?  if so, how can i do it?
  10. well, i didnt want to have to post the code here too, but if that is what you want me to do in order to help, no problem.  here is the current code. [code] <?php $level = "SELECT `id`, `user`, `level` FROM  `login` WHERE `user` = " . $_SESSION['user'] . " AND level = 1"; // Check if the level is equal to admin or demo $result = mysql_query ($level); // Run the query if (mysql_num_rows($result) == 0){ echp 'do the required task'; include('includes/admin_footer.php'); exit(); } } else {  // Print and error is admin level is set to demo Print 'Error: You do not have access.'; include('includes/admin_footer.php'); exit(); } // End Admin level check ?> [/code] i tried to define the user with the session user, but not sure if i did it right, or if that was the proper way to do this. do i need to maybe defin a value for something like $level such as if ($level == 1) {     echo 'do this'; }else{     echo 'error message'; } that is just a stab in the dark.  :S  also, in that little attempt above, would the session need to be included there along with the level and == 1?
  11. ok, here it goes.  i am working on a backend for my new hosting site, and i would like to have at least one admin account, possibly more in the future, and one demo account, possibly more in the future too.  i have the database set as follows: table name = login id = primary key/number value user = user name pass =  password email = email address for the user in case it is forgotten level =  number value of 0 or 1 (0 being demo account, and 1 being admin level acocunt) I have created the admin area as so.  any  user that is admin or demo can lig in to the site and look around at all the things to do, but once any change to the database is attemped, it needs to look and see what user is attempting to make the change, and check to see if that user has a level of 1 or 0.  if the level is equal to 1, then proceed with the chage, and if it is not equal to 1, then print an error message.  here is a link to the site i previously posted my problem on, but didnt get any significant help.  i dont want to go through posing all the code here again if i can avoid it.  if you read the most recent post there, you can see the code i am currently attempting to use, and tell me what is wronge hopefully and then maybe be able to help fix the code to work properly. http://freewebspace.net/forums/showthread.php?t=2178866 thanks for any help in advance.
  12. ok, i looked for someone asking about these options already, but saw nothing, so here it goes. I am currently using the php photo album from [a href=\"http://dynamicdrive.com/dynamicindex4/php-photoalbum.htm\" target=\"_blank\"]http://dynamicdrive.com/dynamicindex4/php-photoalbum.htm[/a] on [a href=\"http://www.smokingwoodies.com\" target=\"_blank\"]http://www.smokingwoodies.com[/a] and it is working great. I however would like to add a couple things into it, and i am stumped. i would like to have the images pull up in a new window like they already do, but i would like the window to resize to the size of the image. similar to the gallery here. [a href=\"http://www.methodcomptech.com/samplework.php\" target=\"_blank\"]http://www.methodcomptech.com/samplework.php[/a]. so obviously i would like it to have the option to scroll through the images from the popup instead of having to close the image, and then click a new one. i would also like to have a slideshow option that the user can change how fast the slideshow is showing. default it to like 3 seconds, and they can set it anywhere from 1 - 10 seconds while in slidshow mode. if anyone can help me with at least a couple of these thing, if not all 3, it would be greatly appreciated. thanks in advance for any help.
  13. [!--quoteo(post=379310:date=Jun 2 2006, 05:40 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 2 2006, 05:40 AM) [snapback]379310[/snapback][/div][div class=\'quotemain\'][!--quotec--] You need help in the javascript section ok. [/quote] i will post there too then. i just posted here beacuse it is also php, but thanks.
  14. so, anyone out there that can help?
  15. ok, i looked for someone asking about these options already, but saw nothing, so here it goes. I am currently using the php photo album from [a href=\"http://dynamicdrive.com/dynamicindex4/php-photoalbum.htm\" target=\"_blank\"]http://dynamicdrive.com/dynamicindex4/php-photoalbum.htm[/a] on [a href=\"http://www.smokingwoodies.com\" target=\"_blank\"]http://www.smokingwoodies.com[/a] and it is working great. I however would like to add a couple things into it, and i am stumped. i would like to have the images pull up in a new window like they already do, but i would like the window to resize to the size of the image. similar to the gallery here. [a href=\"http://www.methodcomptech.com/samplework.php\" target=\"_blank\"]http://www.methodcomptech.com/samplework.php[/a]. so obviously i would like it to have the option to scroll through the images from the popup instead of having to close the image, and then click a new one. i would also like to have a slideshow option that the user can change how fast the slideshow is showing. default it to like 3 seconds, and they can set it anywhere from 1 - 10 seconds while in slidshow mode. if anyone can help me with at least a couple of these thing, if not all 3, it would be greatly appreciated. thanks in advance for any 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.