Jump to content

Ell20

Members
  • Posts

    337
  • Joined

  • Last visited

    Never

Everything posted by Ell20

  1. Hey, I have a database of news items. On the news page all news items related to the particular club that the user is logged into is displayed. I want the admin of the club to be able to edit each particular message by clicking a link "Edit News" which will be displayed under each news item if you are an admin. Once "Edit News" has been selected I would like the message to be placed into the textarea for editing. Then once submitted the new item is updated. I have done a similar thing without the edit button (see code) however for this example it updates all the news items with the same information. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" align="center" cellspacing="0" border="0" class="game"> <tr> <th> Edit News: </th> </tr> <tr> <td align="center"> <?php echo "<textarea cols=\"91\" rows=\"10\" name=\"message\">{$message}</textarea>"; ?> </td> </tr> <tr> <td align="center"> <?php echo "<input name=\"submit\" type=\"submit\" />"; ?> </td> </tr> <?php echo "</form>"; if (isset($_POST['submit'])) { $message = $_POST['message']; $update = "UPDATE news SET news='$message' WHERE club_id='$club_id'" or die(mysql_error()); mysql_query($update) or die(mysql_error()); echo '<center><h3>Message Updated!</h3></center>'; }}}}} ?> Thanks for any help
  2. Just discovered a typo on one of the suggestions. Working now, thanks alot
  3. Thanks for the suggestions. Im ok connecting to database. I get this error from your suggestions: Suggestion 1: An error occured in script c:\program files\easyphp1-8\www\html\news.php on line 41: Undefined variable: resultAn error occured in script c:\program files\easyphp1-8\www\html\news.php on line 41: mysql_fetch_array(): supplied argument is not a valid MySQL result resource Suggestion 2: An error occured in script c:\program files\easyphp1-8\www\html\news.php on line 41: Undefined variable: resultAn error occured in script c:\program files\easyphp1-8\www\html\news.php on line 41: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Cheers
  4. Hey guys, Ive got my page set up correctly as far as getting data into the database goes however I am not sure how to display it all on the page. Basically I have a news table: news_id, club_id, title, news I would like to display all the news items associated with the club that the user is logged into. Id like each news item to be separated so that its easy to identify they are different news items e.g. __________________________ $title $news __________________________ $title $news __________________________ Appreciate any help Cheers Elliot
  5. Ell20

    Text Area Tags

    Thanks for the link but I cant do this as its a project and I have to create it myself, is there anyway I can do this without using a plugin such as this? Cheers
  6. Ell20

    Text Area Tags

    Hey, Im looking for some help regarding text area tags such as <b></b> To make it easier for my user is there a way in which I can create a link e.g Bold, when clicked it creates the tags automatically ready for the user to input the text between the tags. Exactly the same way as you use on this forum but just with simple links like Bold Text, Italic Text etc? Cheers
  7. Thanks alot for your help. I got 1 error: An error occured in script c:\program files\easyphp1-8\www\html\main.php on line 63: Undefined variable: PHP_SELF Also, this works providing there is a message already set in the database, however originally when a new club is registered there is no message in the database just a simple output message, how would I go about creating a new blank entry from which the admin can type whatever they wish as the message? Figured it would be just as easy to set the message to "No message has been set yet" on the registration page? Any ideas on the error though? Cheers
  8. Thanks for the help in the code however im still kinda learning my way with PHP. When you say "some query" what do you mean by that? My tables are: - users: user_id, club_id, member_type, username, first_name, last_name, email, password, registration_date - club: club_id, clubn, webtype - welcome: welcome_id, club_id, welcome Cheers
  9. Hey guys, Once my user has logged in I would like a welcome message to be displayed once the Admin has set this up. At the moment if the user logs in and there is no welcome message set by the Admin there is a message displayed "No welcome message set yet". However I need a button which is only available to Admins to create a message if there isnt one or edit the message if they would like to change something. I have created the code so that if the user logged in is Admin they will see the option Edit Update (this is just text at the moment, no link) How would I go about making it possible to create/edit the message? My code so far: <?php $club_id = mysql_query("SELECT club_id FROM users WHERE user_id = '{$_SESSION['user_id']}'") OR DIE(mysql_error()); $row = mysql_fetch_assoc($club_id); $club_id = $row['club_id']; $clubname = mysql_query("SELECT clubn FROM club WHERE club_id = '$club_id'") OR DIE(mysql_error()); $row = mysql_fetch_assoc($clubname); $clubname = $row['clubn']; $message = mysql_query("SELECT welcome FROM welcome WHERE club_id = '$club_id'") OR DIE(mysql_error()); $row = mysql_fetch_assoc($message); $welcome = $row['welcome']; if (isset($welcome)) { echo $welcome; } else { $welcome = 'No welcome message set yet'; echo $welcome; } ?> </td> </tr> <tr> <td> <?php require_once ('../mysql_connect.php'); if (isset($_SESSION['user_id'])){ $sql = "SELECT member_type FROM users WHERE user_id = '{$_SESSION['user_id']}' LIMIT 1"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); if ($row['member_type'] == "Admin") {?> Edit Update <?php }}}} ?> </td> </tr> </table> Cheers Elliot
  10. Hey, Im looking for some help in producing a layout for my website. I have produced a login page which works fine and now I would like to produce a standard layout throughout the rest of the website. My ideal layout would be: - The menu (footer.html) to be present on the left hand side of the screen, from the top of the page to the bottom (vertically). - The title/logo (header.html) to be present at the top of the screen, from the menu to the other side of the page (horizontally). - The page loaded to be present in the main section of the page. My attempted drawing: _ _ _ _ _ _ _ _ _ _ | |_ _ _title _ _ | | m | | | e | main | | n | | |_ u| _ _ _ _ __ _ | I have already started making some of the pages but I am unable to get frames/tables working to the layout that I would like. Appreciate any help. If I havent made sense please say and ill do my best to describe it better Cheers Elliot
  11. Hey, Im creating a login page, I want a table to hold 2 tables side by side. However the 2 tables inside the table have a different number of rows so the heading do not align correctly which will make the page look funny. Is there anyway to align the 2 inner tables? I have tried adding another row but it still makes the table look odd. Hope I have explained what im trying to do ok! Cheers for any help
  12. Sorry didnt realise I wasnt suppose to post that here. Apologies.
  13. Hey, Im creating a login page, I want a table to hold 2 tables side by side. However the 2 tables inside the table have a different number of rows so the heading do not align correctly which will make the page look funny. Is there anyway to align the 2 inner tables? I have tried adding another row but it still makes the table look odd. Cheers for any help
  14. Think I may have done it: $club_id = mysql_query("SELECT club_id FROM users WHERE user_id = '{$_SESSION['user_id']}'")
  15. Erm ok now im confused! I dont allow 2 people to have the same username and the user_id is always unique as it is set to auto_increment in the database so each user is given a different ID when they register. At the moment if i typed something like: echo " $_SESSION['first_name']" it comes up with the first name of the user that is logged in, can this not be used for doing this?
  16. I have a variable called user_id but its not set upon login, its set upon register but it is linked to the session if that makes sense? Here is the error: An error occured in script c:\program files\easyphp1-8\www\html\main.php on line 25: Undefined variable: user_id Cheers
  17. Thanks for the reply. My session is actually setup through user_id which is in the users table. Ive had ago at using your table but I think I may have made a mistake as it dosent work. Tables: club: club_id, clubn, user_id users: username, user_id, club_id welcome: welcome_id, club_id, welcome Thanks
  18. I have already done the top bit that you mentioned. Would it be possible for you to give me some idea as to how to do the second part? Cheers
  19. Hi, Im making a website where users sign up to a club each user has a user_id and each club has a club_id. On the first page after logging in I want to be able to include a standard welcome message which will say something like "Welcome to $clubname". Then once the admin signs in he then has the ability to edit the post and write some information on the club and save it. However within the website there are lots of different clubs so I need the message that applies to a particular club to only be visible if the user is linked to the club. My database has 3 tables, 1 for users, 1 for clubs and 1 for welcome. Can anyone give me some help as to how to do this as I am still very new to php. If you need any extra information then just ask. Thanks for your help Elliot
  20. Excellent working - Cheers Thank you both for your help, its appreciated Elliot
  21. Amazingly enough yeah: user_id club_id member_type username first_name last_name email password registration_date 1 1 Admin Ell20 Elliot Reeve ell@reeve.plus.com 37e455b94f62fb0d 2007-10-13 Cheers
  22. Hmm...made the suggested changes: If log in as Admin: "Unknown column 'Admin' in 'where clause'" If log in as Member: Unknown column 'Member' in 'where clause' Cheers
  23. Getting there.....I think: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Thanks
  24. I changed your line slightly and got this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' WHERE member_type=Admin' at line 1 Cheers
×
×
  • 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.