Jump to content

gangsterwanster1

Members
  • Posts

    80
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gangsterwanster1's Achievements

Member

Member (2/5)

0

Reputation

  1. so can anyone help me figure out how from php to clear a database?
  2. How can i from a command button re-set a database so no entries are entered?
  3. would the different be how it starts but the values are the same? (<img src=)
  4. Is there a way to get a image to act as a command button? Meaning in commandbuttons you get this, <input type="submit" name="submit" value = "22" so that it redirects you or does a action. Can i acomplish the same thing but with a image?
  5. I got it to work perfectly for the test but now i am having troubles implementing it in my main code. <?php mysql_connect("localhost", "root", "") mysql_select_db("maindb") // delete button selected if($_POST['action'] && $_POST['action'] == 'delete') { if(count($_POST['input'])) { // delete records mysql_query("DELETE FROM table WHERE id IN(".implode(",",$_POST['input']).")"); // reload page header("Location:test.php"); exit(); } } print "<form method='post'>\n"; print "<input type='hidden' name='action' value='delete' />\n"; // select data $result = mysql_query("SELECT cid, title FROM logs ORDER BY title ASC"); while($row = mysql_fetch_object($result)) { print "<input type='checkbox' name='input[]' value='".$row->id."' /> ".$row->title."<br />\n"; } print "<input type='submit' name='submit' value='delete selected' />\n"; print "</form>"; ?> Can you provide an example that uses the above method but does the following? 1.) Makes four rows (username, date, comment, delete check mark) So like this, Bill - 2009 - Loves - [] check mark John -2009 - Hates - [] checkmark (the four rows are four columns from the database) 2.) Once the information has been read from the database and the rows are shown with the four separate areas then at the bottom of the page can there be 1 delete button, which if i select any of the check marks on the page it automatically deletes it? Sorry for asking for so much i have been working on this for a while and i cant figure it out.
  6. I get this error; Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\test\test.php on line 21 'while($row = mysql_fetch_object($result)) {' Any idea why i get this? All i added was mysqlconnect // mysqlselect database
  7. I am using mysql_num_rows() to show some database information in columns/rows. How can i do it so that i can delete the row from the site? Like by adding a command button to delete every row that has a check on the check mark?
  8. Finally!! Thanks a LOT everyone, finally solved it. ~i have one minor question with the code you posted and then i am done. If i wanted it to delete duplicates based on more then one row would i do this? ON (bad_rows.username = good_rows.username AND ON (bad_rows.password = good_rows.password AND bad_rows.id > good_rows.id)"; Because i tried that and it comes up with this erorr; 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 'ON (bad_rows.password = good_rows.password AND bad_r' at line 8
  9. AHHHH 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 4
  10. Well then i am back to this. <?php $connect = mysql_connect("127.0.0.1", "root", "") or die('Could not connect'); mysql_select_db("MainDB", $connect) or die('Could not select database'); $query = mysql_query("delete bad_rows.* from account as good_rows inner join account as bad_rows on bad_rows.username = good_rows.username and bad_rows.id > good_rows.id)", $connect) or die(mysql_error(); mysql_close($connect) or die(mysql_error()); ?> Do you have a database with duplicates where you can try the code out? Same code as before, all i changed was $query = mysql_query("DELETE bad_rows.* FROM account AS 'good_rows' INNER JOIN account AS 'bad_rows' ON (bad_rows.username = good_rows.username AND bad_rows.id > good_rows.id)", $connect) or die(mysql_error()); But then once i got the error i changed it back to what it was earlier.
  11. I get this error now; Parse error: parse error in C:\xampp\htdocs\Project\test.php on line 8 With your code i get this; 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 ''good_rows' INNER JOIN account AS 'bad_rows' ' at line 2 This is so annoying, it works in phpadmin yet i am having all these troubles using it in php.
  12. <?php $connect = mysql_connect("127.0.0.1", "root", "") or die('Could not connect'); mysql_select_db("MainDB", $connect) or die('Could not select database'); $query = mysql_query("delete bad_rows.* from account as good_rows inner join account as bad_rows on bad_rows.username = good_rows.username and bad_rows.id > good_rows.id)", $connect) or die(mysql_error(); mysql_close($connect) or die(mysql_error()); ?>
  13. My bad i missed that, but now i get this; Parse error: parse error in C:\xampp\htdocs\Project\test.php on line 7 Line 7 is bad_rows.id > good_rows.id)", $connect) or die(mysql_error();
  14. 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 ')' at line 4 -Using the latest version of XAMPP so i can test it locally before i put it on the net. Full code <?php $connect = mysql_connect("127.0.0.1", "root", "") or die('Cant connect'); mysql_select_db("MainDB", $connect) or die('Cant select database'); $query = mysql_query("delete bad_rows.* from account as good_rows inner join account as bad_rows on bad_rows.username = good_rows.username and bad_rows.id > good_rows.id)", $connect) or die(mysql_error()); mysql_close($connect) or die(mysql_error()); ?>
×
×
  • 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.