Jump to content

Icewolf

Members
  • Posts

    59
  • Joined

  • Last visited

Everything posted by Icewolf

  1. What do you mean if you give them the same name? I thought if I use Name="" defines the button. The filter button works just fine. Then when I hit the Update button I can see the values are coming over I am just getting an error message "Invalid query: Query was empty Whole query:"
  2. Okay I think I understand what you all are saying but I don't know if I did it right. I can get the filter button to work but not the submit. HTML <!DOCTYPE HTML> <html> <head> <title>Icewolf is the Man!!</title> </head> <body> <Form action="Dropdown_new.php" method="POST" target="showhere"> <select name="Member_ID"> <option value="">Select one…</option> <option value="Icewolf">Icewolf</option> <option value="Travisr826">Travisr826</option> <option value="josehasthestick">josehasthestick</option> <option value="Hhn87">Hhn87</option> <option value="Twisted31007">Twisted31007</option> <option value="Midget_chunkin">Midget_chunkin</option> <option value="cashstro718">cashstro718</option> <option value="mpnak313">mpnak313</option> <option value="Wisconsin24">Wisconsin24</option> <option value="usmc57-2">usmc57-2</option> <option value="Derbin11">Derbin11</option> <input type="submit" name="filter" value="filter"> </select> Bank: <input type="text" name="bank" /> Reward 1: <input type="text" name="reward1" /> Reward 2: <input type="text" name="reward2" /> Reward 3: <input type="text" name="reward3" /> <input type="submit" name="submit" value="Update" /> </form> <iframe width="800" height="100" name="showhere" marginheight="0" marginwidth="0" frameborder="0" scrolling="no"> </iframe> </body> </html> PHP <?php $username = "Userid"; $password = "Password"; $hostname = "localhost"; //connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "<font face=tahoma color=#ff000><b>Connected to MySQL</b></font><br><br>"; //select a database to work with $selected = mysql_select_db("pdogclan_points",$dbhandle) or die("Did this change"); // Formulate Query if (isset($_POST['filter'])){ $memid = mysql_real_escape_string($_POST["Member_ID"]); $query = sprintf("SELECT Member_ID, Bank, Reward_1, Reward_2, Reward_3 FROM Points_Rewards WHERE Member_ID = '$memid'") or die("Could Not Formulate the Query"); } //execute the SQL query and return records $result = mysql_query($query); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. //if (!$result) { // $message = 'Invalid query: ' . mysql_error() . "\n"; // $message .= 'Whole query: ' . $query; // die($message); //} //fetch tha data from the database while ($row = mysql_fetch_array($result)) echo "<table width=750 cellspacing=2 cellpadding=2 border=2> <tr> <td bgcolor=#000000 width=150><font face=tahoma color=white>ID: {$row['Member_ID']}</font></td>". "<td width=150><font face=tahoma>Bank: {$row['Bank']}</td>". "<td width=150><font face=tahoma>Reward 1: {$row['Reward_1']}</td>". "<td width=150><font face=tahoma>Reward 2: {$row['Reward_2']}</td> ". "<td width=150><font face=tahoma>Reward 3: {$row['Reward_3']}</td> </tr> </table><br></font>";//display the results // Formulate Update Query Else if (isset($_POST["submit"])){ $memid = mysql_real_escape_string($_POST["Member_ID"]); $bank = $_POST['bank']; $reward1 = $_POST['reward1']; $reward2 = $_POST['reward2']; $reward3 = $_POST['reward3']; } $query = "UPDATE Points_Rewards Set Bank = '$bank', Reward_1 = '$reward1', Reward_2 = '$reward2', Reward_3 = '$reward3' WHERE Member_ID = '$memid'"; $result = mysql_query($query) or die(mysql_error()); //echo $query; //if(mysql_query($query)){ //echo "updated";} //echo "fail";} //close the connection mysql_close($dbhandle); ?>
  3. Thanks Mac I was wondering this but how do use two different buttons on here to work. One is to pull the information the other is to update the information. AK I wasn't sure how to get the two buttons to work on one form.
  4. You are correct. It is not pulling the member_id. How do I get to the ID if it is on another form? Do I need to create another drop down in this form?
  5. I did try that but I am still getting a fail. I am thinking it is getting here and failing. if(mysql_query($query)){ echo "updated";} else{ echo "fail";}
  6. Yes I did after I posted it. I hard coded the data to see if I can get it to work but that didn't even work. I am not sure what is causing it to fail. It is running through everythng and gets to the end and fails.
  7. Hi I am trying to create a page that display the information from the database. But also there is a place to update it. I can get it to display correctly but I am having problems with the update. It keeps failing. </HTML> <body> <Form action="Dropdown_new.php" method="POST" target="showhere"> <select name="Member_ID"> <option value="">Select one…</option> <option value="Icewolf">Icewolf</option> <option value="Travisr826">Travisr826</option> <option value="josehasthestick">josehasthestick</option> <option value="Hhn87">Hhn87</option> <option value="Twisted31007">Twisted31007</option> <option value="Midget_chunkin">Midget_chunkin</option> <option value="cashstro718">cashstro718</option> <option value="mpnak313">mpnak313</option> <option value="Wisconsin24">Wisconsin24</option> <option value="usmc57-2">usmc57-2</option> <option value="Derbin11">Derbin11</option> <input type="submit" value="filter"> </select> </form> <iframe width="800" height="100" name="showhere" marginheight="0" marginwidth="0" frameborder="0" scrolling="no"> </iframe> <Form method ="POST" name="update" action="Update.php" /> Bank: <input type="text" name="bank" /> Reward 1: <input type="text" name="reward1" /> Reward 2: <input type="text" name="reward2" /> Reward 3: <input type="text" name="reward3" /> <input type="submit" name="submit" value="Update" /> </form> </body> </html> Here is the PHP <?php $username = "UserName"; $password = "Password"; $hostname = "localhost"; //connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "<font face=tahoma color=#ff000><b>Connected to MySQL</b></font><br><br>"; //select a database to work with $selected = mysql_select_db("pdogclan_points",$dbhandle) or die("Did this change"); // Formulate Query if (isset($_POST["Member_ID"])){ $memid = mysql_real_escape_string($_POST["Member_ID"]); $bank = $_POST['bank']; $reward1 = $_POST['reward1']; $reward2 = $_POST['reward2']; $reward3 = $_POST['reward3']; $query = "UPDATE Points_Rewards Set Bank = '$bank', Reward_1 = '$reward1', Reward_2 = '$reard2', Reward_3 = '$reward3' WHERE Member_ID = '$memid'" or die("Could Not Formulate the Query"); } if(mysql_query($query)){ echo "updated";} else{ echo "fail";} ?> I am getting through all the code but it hitting the last echo. I need to pull the ID from the top form. I don't know if this is correct way to do this. Thanks
  8. Hi Can anyone help me with this code? It looks like it is geting to the part where the SQL is ran but we are getting to the die part of the code. I am trying to figure out am I missing something. I am new to PHP so I am not sure if this is correct or not. I have searched the web and everything looks good to me but I can't figure out what I a missing. Thanks Andy <?php $username = "Entered username"; $password = "entered password"; $hostname = "localhost"; //connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "Connected to MySQL<br>"; //select a database to work with $selected = mysql_select_db("pdogclan_points",$dbhandle) or die("Did this change"); //execute the SQL query and return records $results = mysql_query("SELECT member_id, bank, reward_1, reward_2, reward_3, reward_4 FROM Points_Rewards") or die("Could Not Find Data"); //fetch tha data from the database while ($row = mysql_fetch_array($result)) echo "ID: {$row['member_id']}". "Bank: {$row['bank']}". "Reward 1: {$row['reward_1']}". "Reward 2: {$row['reward_2']}". "Reward 3: {$row['reward_3']}". "Reward 4: {$row['reward_4']}";//display the results //close the connection mysql_close($dbhandle); ?>
×
×
  • 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.