Jump to content

Aezel

Members
  • Posts

    9
  • Joined

  • Last visited

Aezel's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. In the admin part of my site I want to create a page where admins can delete users (members).I've made a page that calls all members with a checkbox beside every name. If checked the member should be deleted on submit.Here's the code for that page: <form action="url/members_delete.php" method="post" name="members_del"><?php$sql->QueryRow("SELECT * from members ORDER BY player");for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i); $player = $sql->data[2]; $class = $sql->data[3]; $profone = $sql->data[4]; $proftwo = $sql->data[5]; $delbox = $sql->data[6];?> <tr> <td width="20%"> <input type="checkbox" value="1" name="delbox"> --------------></td> <td width="80%"> <?php echo"$player";?></td> </tr><?php}?> <tr> <td> <input type="submit" value="Submit"></td> <td> </td> </tr></form> The delbox field is int(1) with a default value of 0.The action page looks like this: <?php require("url/php/db.inc.php"); $sql = new MySQL_class; $sql->Create("mydb"); $sql->Delete("DELETE FROM members WHERE delbox=1"); $affected_rows = $sql->a_rows; header("Location: url/confirm.html");?> The idea was that when the box is checked it gets the value "1" and all of the checked members would be deleted.I do not get any error messages, it's just that nothing happened when I get to the confirmation page.I think the problem is that the delbox value isn't changed to 1 but I can't see why it isn't.. I have tried an sql update page in between of the form and the sql delete page, to update the delbox value first, but no success there either. Again no error message and no change even tho I get the confirmation page.Can somebody please give me some pointers or even better, show me how to make it work? Thanks .
  2. Nvm I fixed it.I added an <input> field to the form called raidday where we enter the date YYYY-MM-DD.Then I made the new raidday field (date) in the database and it works fine now with this query: SELECT * from events WHERE raidday>=date( NOW()) ORDER BY month, day LIMIT 4 Thanks again for your help .
  3. Yes please if it's not too much trouble cause I'm not sure what u mean.
  4. I now have 2 fields (both int(2) ), one for month and one for day. That's because on the form where we post the events, there's a dropdownbox for both fields. One with values 1-12 for month and one for day (values 1-31).So I should drop these 2 fields and make a new one (type: date), and then we should simply type the date of the event into a textfield at the form?Is that what you mean I should do?
  5. Thx for your reply.By actual full date you mean with $date? That would be the posting date then right?It needs to be ordered chronologically by future dates cuz the upcoming events are all in the future. I couldn't think of another way to post future dates with the html form me and the co-leaders of the guild use.So $date wouldn't help me too much; when someone else adds an event that is to take place 2 days earlier it would still be displayed after the other event, even tho the other event will take place later (not chronologically displayed). I hope this makes sense lol.Maybe u know of a better way to post future dates to the sql database so I can indeed work with "getdate". Or am I just missing your point?The page in question
  6. I've made a site for my game guild. On the pages i have a section where upcoming guild events are displayed with the following query: SELECT * from eventsWHERE month >= MONTH( NOW())AND day >= DAY(NOW())ORDER BY month, day LIMIT 4 The values for month are 1-12 (Jan-Dec) and the values for day are 1-31. Year is not posted so irrelevant to this code at the moment.The values are posted with a html form, <select> (<option>) to be exact. I'm new to SQL/PHP and couldn't think of another way to post future dates into the sql database.This query worked fine until now. I posted a new event that will take place next month, April 1st. It doesn't show up on the events section of the webpage.Can somebody please show me a query that will make all upcoming events show up on the pages? Even when the month is different?To me the query looks like it should display all events that are later than the current date.. I'm really lost here.Any help would be greatly appreciated.
  7. Aezel

    multiple table query

    Hehe that's how new I am to this; I posted in the wrong forum . Sorry for that.Thanks for your help, I solved the problem. I did close the loop before, at the end of the "headlines" table that is generated with the first query.I made the mistake of placing the query for "events" inside the same loop as the "headlines". So I now moved the "events" query to the table where that specific data has to be generated and it all works .I already had a close loop "}" at the end of the "events" table, I'm guessing that's why the misplaced query did return one result at the designated table, even though the query was in the headlines loop.Anyways thanks again, it works like a charm now.
  8. Aezel

    multiple table query

    Thank you for replying sbrownii but I'm afraid you're gonna have to spell it out for me. I really don't know much about SQL at all and have only been modifying existing code to work with my own tables.What do u mean by closing for loops?
  9. Aezel

    multiple table query

    HI,Please excuse me if the answer to my question has already been posted but i couldn't find it. I'm new to SQL and i have a problem with doing a query from two different sql tables onto the same php page.One table is "headlines" which should display the 3 most recent table entries and the other table is "events" which should display the latest 4 table entries.I made the headlines table and sql/php code first and it all worked fine on the php page where the sql data is called with SELECT.After that i added the events table and now the target php page displays only the most recent "headlines" entry 3 times (the same entry 3 times), and the most recent "events" entry is displayed only once..This is the sql code on the php target page i have now: <?phprequire("/mydb");$sql = new MySQL_class;$sql->Create("mysite");$sql->QueryRow("SELECT * from headlines ORDER BY headlines_id DESC LIMIT 3");for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i); $date = $sql->data[1]; $user = $sql->data[2]; $message = $sql->data[3];$sql->QueryRow("SELECT * from events ORDER BY month, day LIMIT 4");for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i); $weekday = $sql->data[1]; $month = $sql->data[2]; $day = $sql->data[3]; $type = $sql->data[4]; $location = $sql->data[5]; $comment = $sql->data[6]; ?> The first query worked perfectly on its own. The problem started when i added the second.How do i combine the 2 $sql->QueryRow parts so both are called correctly at the same page?I'm a total noob at this . So far I have only used existing code that a friend made once and modified it to work with my own tables. But now i need some expert counselling.Any help would be greatly appreciated .
×
×
  • Create New...