Jump to content

Recommended Posts

im making this tool to clean up some data from a sql database, i made a php code to list what i need, thats player name,lvl and id from  table_A, the problem is i want to delete from  table_A and from table_B all the results from php code , they have in common the id and as a condition the lvl must be lower then 10, it seems i cant make it delete from table_B also,please help me!!

 

a button of the end of the page to delete all that includes same id from both tables is what im looking for!

 

<table<?php echo $tableSet; ?>>
  <tr>
    <td width="*" align="center">Rank</td>                                       
    <td width="*" align="center"><font color="#000000">Name</td>
   <td width="*" align="center"><font color="#000000">money</td>
   <td width="*" align="center"><font color="#000000">id</td>
   <td width="*" align="center"><font color="#000000">lvl</td>


  </tr>
  
<?php				
$rank = mysql_query('SELECT name,money,id,level  FROM table_A  WHERE level < 10 '
      .' ORDER by level desc LIMIT '.$limit.';');
$i=1;
while ($row = mysql_fetch_array($rank)) {
	echo '<tr><td align="center">'.$i.'.</td>
      <td align="center"><font color="#0000FF">'.$row['name'].'</td>
  <td align="center"><font color="#0000FF">'.$row['money'].'</td>
  <td align="center"><font color="#0000FF">'.$row['id'].'</td>
      <td align="center"><font color="#FF0000">'.$row['level'].'</td>

    </tr> ';
    $i++;
    }
?>

this is showing which player names goes to id(from table_A)

i need to delete from table_a where the ids shown are lower then lvl 10(the ones result from code above) and same ids from table_b

(the rank is just to show me ho is highest lvl)

Link to comment
https://forums.phpfreaks.com/topic/251047-need-help-on-php-sql-2-table-action/
Share on other sites

before posting here i have tried many codes, the one u posted also but as u can see i also req the level <10 condition which is only in table_a so thats my biggest problem it should look like delete from table_a, table_b common ids where from table_a lvl<10 same ids, been surfing the net for almost 2 weeks and i still didnt found a solution, so i thought resulting first from table_a the ids and then a php -sql action to delete the same ids from table_b

no tested that already result is affected rows 0 :( its like the lvl condition doesnt aplly well,thats why im looking for php result and then delete results, in sql i didnt found a way to put a condition from a table to affect dfferent table, but if its a result in php first, i think it will affect the second table also, i really need a php guru help here!!!!!!!!

 

and thx russell for the support!

You don't need a php guru, what you're asking for is accomplished with my above query, you need to change some values to accomplish this, to relate this query to your database structure..

 

And if you really did need a php guru, You're probably talking to one, I just don't have the tag under my name, but that doesn't change the fact that I've been developing for 7 years.. Try the query again

the thing is that all sql command didnt work before posting on forum, the above one included

the only 1 had a semi result was last night it looked like this:

 

delete from table_b where player_id = 'select player_id from table_a where level <10'

 

after this is easy to delete from table_a, but the query above had 0,600 results on screen but i cant see if content of table_b modiffied cuz its a very large amount of data has around 700 sql pages

 

so im turning at u now whit 1 more solution: how about on the php code above, the first one where it shows player name,lvl and id to be a delete button for every row which deletes from table_b

 

like table_a results

 

 

rank         name        level           id         button

1             test            9            999       delete                         <----------- from table_b

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.