beansandsausages Posted January 7, 2008 Share Posted January 7, 2008 Hey all, My problem is ...... i have a script that gets the information from the db as followed : $game_show = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ORDER BY 'id' DESC ")) or die('Error: ' . mysql_error()); that works fine, when it brings the results up i want it to have a option to edit the details : <input type=text name=\"update\" value=".$on['game_show']." size=1> <input type=submit value=update> i just dont know how to save it in the database on that page, i mean all the results will had diffrent values etc.. i have tried severl things and all just dont work. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/ Share on other sites More sharing options...
Ken2k7 Posted January 7, 2008 Share Posted January 7, 2008 Please post your form and the rest of your PHP code. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432605 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 current code i am using is : if($_GET[action] == 'update_off' ) { //second level security if($info[security] <= '7' ) { $page_to_view = " Tried to view who has update off. "; echo " <br /><br />$space<span style=\"color: orange\"> <strong>Unable to view this page. Level 7 security or higher required. This action has been logged.<strong></span> "; $sql = "INSERT INTO `logged_1` (`id`, `username`, `player_id`, `page_to_view`, `ip_address`) VALUES ('','" . $info['username'] . "', '" .$info['id']. "', '" . $page_to_view . "', '$info[ip]')"; if ( !$result = mysql_query($sql) ) { die('MySQL Error: ' . mysql_error()); } } else { echo " "; ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <?php echo "<br /> <br /> $space This is all game members who have the update messages turned <strong>off</strong>. <br />"; echo " $space <table width=\"50%\"> <td width=\"15%\">$space <u>Username</u></td> <td width=\"10%\"><u>Game Id</u></td> <td width=\"15%\"><u>Action</u></td> <td width=\"15%\"><u>Change</u></td></table>"; $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ORDER BY 'id' DESC ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)) { echo " <table width=\"50%\"> <td width=\"15%\"> $space <a href=\"view.php?\">" .$on['username']. "</a></td> <td width=\"10%\">" .$on['id']. "</td><td width=\"15%\">Contact</a></td><td width=\"15%\"><select><option value=No selected>No</option><option value=yes >Yes</select></option> <input type=submit value=update></td></table>"; } } } Now i get a option value for each player but i cant seem to get it to work, i know there no form stuff in there i have just deleted it in a spit of madness {mad} argh .. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432620 Share on other sites More sharing options...
trq Posted January 7, 2008 Share Posted January 7, 2008 Your form needs to submit to a script which executes a mysql UPDATE statement. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432622 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 how would i do that, i mean where will i set the id so it knows what to change Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432623 Share on other sites More sharing options...
Ken2k7 Posted January 7, 2008 Share Posted January 7, 2008 <input type='submit' name='submit' value='submit' /> ? Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432625 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 yeah i know that, just in the form it needs to change the correct id for the player what is what got me, if you understand what im saying Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432626 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 sum it like this maybe? if( $_GET['action'] == 'edit' && $on['id'] ) { echo " woot woot ";} Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432631 Share on other sites More sharing options...
adam291086 Posted January 7, 2008 Share Posted January 7, 2008 Yeah that will work. When the button edit is clicked set your url to contain the name edit and the ID number. Then in your script have a switch statement that relies on either edit or delete. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432641 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 i have tried that but just get a blank screen Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432645 Share on other sites More sharing options...
adam291086 Posted January 7, 2008 Share Posted January 7, 2008 show us the code and maybe we can work out. It should work Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432649 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 the link is : <a href=?action=override&id=".$on['id'].">Change</a> php code when link is clicked is : if($_GET['action'] =='override&$on[id]') { echo " ".$on['id']." "; } when link is clicked it displays the wrigh info : http://localhost/public/mem.php?action=override&id=2 just returns a blank page tho Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432650 Share on other sites More sharing options...
Ken2k7 Posted January 7, 2008 Share Posted January 7, 2008 sum it like this maybe? if( $_GET['action'] == 'edit' && $on['id'] ) { echo " woot woot ";} Since you used the method "POST" in your form, you need to use $_POST in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432651 Share on other sites More sharing options...
adam291086 Posted January 7, 2008 Share Posted January 7, 2008 Right set your form method to "get" if you want to post information in the url. It will be easier if we used post. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432653 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 i have got rid of the form, so how would i do it in links sorry im having a bad day have just wiped out half my database Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432654 Share on other sites More sharing options...
Ken2k7 Posted January 7, 2008 Share Posted January 7, 2008 i have got rid of the form, so how would i do it in links sorry im having a bad day have just wiped out half my database http://domain.com?action=edit You just redirect the user to that once submitted. And you should leave the form in there. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432656 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 the user isnt edit it its like a managment option to override one of there settings, Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432659 Share on other sites More sharing options...
adam291086 Posted January 7, 2008 Share Posted January 7, 2008 I am really confused now. What exactly do you want? Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432660 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 okay ill try explane it again. I have this code : $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ORDER BY 'id' DESC ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)) Witch works fine, it displays all members whos game_show is set to N, Then it displays them in a list : User_1 id_990 | Change User_2 id_009 | Change User_3 id_954 | Change User_4 id_456 | Change The change is a form button : <input type=text name=update value=".$on['game_show']." size=1> <input type=submit value=update> What i need is to de able to hit the change button and it change the layout. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432759 Share on other sites More sharing options...
adam291086 Posted January 7, 2008 Share Posted January 7, 2008 ok. What layout do you want to change. Where is the new layout coming from? Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432762 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 sorry b4 click change there a text box with Y or N depending on what enter in te text box changes i can get it to change but cant get it to change for a indvijual user. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432768 Share on other sites More sharing options...
adam291086 Posted January 7, 2008 Share Posted January 7, 2008 post all your current code, with the form Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432774 Share on other sites More sharing options...
beansandsausages Posted January 7, 2008 Author Share Posted January 7, 2008 [code]CODE SORRY FOR CAPS BROKE BUTTON if($_GET[action] == 'update_off' ) { //second level security if($info[security] <= '7' ) { $page_to_view = " Tried to view who has update off. "; echo " <br /><br />$space<span style=\"color: orange\"> <strong>Unable to view this page. Level 7 security or higher required. This action has been logged.<strong></span> "; $sql = "INSERT INTO `logged_1` (`id`, `username`, `player_id`, `page_to_view`, `ip_address`) VALUES ('','" . $info['username'] . "', '" .$info['id']. "', '" . $page_to_view . "', '$info[ip]')"; if ( !$result = mysql_query($sql) ) { die('MySQL Error: ' . mysql_error()); } } else { echo " <form action=\"mem.php?action=update\" method=\"post\"><br /> <br /> $space This is all game members who have the update messages turned <strong>off</strong>. <br />"; [/code] AND LINK BIT if($_GET['action'] =='update' ) { echo " ".$_POST["game_show"]." "; } SORRY I BETS ITS DEAD BASIC. echo " $space <table width=\"50%\"> <td width=\"15%\">$space <u>Username</u></td> <td width=\"10%\"><u>Game Id</u></td> <td width=\"15%\"><u>Action</u></td> <td width=\"15%\"><u>Change</u></td></table>"; $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ORDER BY 'id' DESC ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)) { echo " <table width=\"50%\"> <td width=\"15%\"> $space <a href=\"view.php?\">" .$on['username']. "</a></td> <td width=\"10%\">" .$on['id']. "</td><td width=\"15%\">Contact</a></td><td width=\"15%\"><input type=text name=update value=".$on['game_show']." size=1> <input type=submit value=update></td></table>"; } echo "<br /><br /> $space <a href=mem.php>Finished</a> "; } THIS BIT OF CODE IS WHERE IF I CHANGE IT TO Y GET A DIFF LAYOUT input type=text name=update value=".$on['game_show']." size=1> Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432780 Share on other sites More sharing options...
adam291086 Posted January 7, 2008 Share Posted January 7, 2008 i am about to pop out and will be back soon. At a quick glance echo " <form action=\"mem.php?action=update\" method=\"post\"> should be echo " <form action=\"mem.php?action=update\" method=\"get\"> Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432783 Share on other sites More sharing options...
Ken2k7 Posted January 7, 2008 Share Posted January 7, 2008 burnside, I don't get what you're trying to do. Your code is 'stupid' in a way. You're telling it to check if security is <= 7, and if so, you display an error and do something with the query which I don't know what. Otherwise, print out the form. No where in that code does it submit data to the database once a form is submitted and security is > 7. Here, I rewrote your code a bit: (this uses $_POST and not $_GET. Don't use $_GET since you're not understanding it) <?php if($_POST['submit']){ //second level security if($info[security] <= '7' ){ $page_to_view = " Tried to view who has update off. "; echo " <br /><br />$space<span style=\"color: orange\"> <strong>Unable to view this page. Level 7 security or higher required. This action has been logged.<strong></span> "; $sql = "INSERT INTO `logged_1` (`id`, `username`, `player_id`, `page_to_view`, `ip_address`) VALUES ('','" . $info['username'] . "', '" .$info['id']. "', '" . $page_to_view . "', '$info[ip]')"; $result = mysql_query($sql) or die(mysql_error()); } else { // Ken2k7: this is doing nothing, please finish this // echo " "; ?> <form method="post"> <?php echo "<br /> <br /> $space This is all game members who have the update messages turned <strong>off</strong>. <br />"; echo " $space <table width=\"50%\"> <td width=\"15%\">$space <u>Username</u></td> <td width=\"10%\"><u>Game Id</u></td> <td width=\"15%\"><u>Action</u></td> <td width=\"15%\"><u>Change</u></td></table>"; $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ORDER BY 'id' DESC ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)){ echo " <table width=\"50%\"> <td width=\"15%\"> $space <a href=\"view.php?\">" .$on['username']. "</a></td> <td width=\"10%\">" .$on['id']. "</td><td width=\"15%\">Contact</a></td><td width=\"15%\"><select name='meselect'><option value='No selected'>No</option><option value=yes >Yes</select></option> <input type=submit name=submit value=update></td></table>"; } } } Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/#findComment-432788 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.