This topic is locked

Process Selected..

6/2/2007 1:14:10 AM
PHPRunner General questions
M
michaelmac author

Hey Everyone
I need to use the select buttons on the "list" page, and instead sending it to export or print selected, I need to write those selected to another table? Any hints or already existing code?
Thanks
Mike

M
michaelmac author 6/4/2007

Hey Everyone

I need to use the select buttons on the "list" page, and instead sending it to export or print selected, I need to write those selected to another table? Any hints or already existing code?
Thanks
Mike


I believe an earlier post about mass emails will work fine. My only real question, how can I get the program to stop and prompt for a "text" input that I want to write to the other table. I am a newbie, and learning very fast how to use this wonderful tool..
Mike

J
Jane 6/4/2007

Mike,
here is a step-by-step instruction:

  1. open your page in the HTML mode on the Visual Editor tab. Find this line:
    <!-- delete form -->

and add following code just before:

<A

onclick="if (!confirm('Do you really want to insert these records?')) return false; frmAdmin.a.value='insert'; frmAdmin.submit(); return false;"

href="TableName_list.htm#">Insert selected</A>


2. Proceed to the Events tab, select Before record deleted event and add your code in it.

Here is a sample:

function BeforeDelete($where)

{

//if you click on the delete link

if(@$_POST["a"]=="delete")

return true;
//if you click on the insert link

global $conn;

$str = "select field1,field2 from TableName where ".$where;

$rs = db_query($str,$conn);

$data = db_fetch_aray($rs);

$strSQL="insert into AnotherTableName (FieldName1,FieldName2) values ('".$data["field1"]."','".$data["field2"]."');

db_exec($strSQL,$conn);
return false;

}

M
michaelmac author 6/4/2007

Mike,

here is a step-by-step instruction:

  1. open your page in the HTML mode on the Visual Editor tab. Find this line:

    and add following code just before:
  2. Proceed to the Events tab, select Before record deleted event and add your code in it.

    Here is a sample:


Thank you Jane. I am going to implement the code in the morning. I do have a question though, what does the variable $where represent? I mean I am not sure if I assign it some value, or does it have one already.
This solution (I hope) will allow me the ability to solve a couple of issues. The mass mailing and the mass insert from the _list.php page. I still need to know how to enter a "text" box so my user can enter in a value I will write to the table.
Thanks for all you help
Mike

J
Jane 6/5/2007

Mike,
the best way to see value of $where variable is to print it on the page:

echo "where variable: ".$where;

M
michaelmac author 6/6/2007

Thank You Jane
After looking at what you suggested, I believe I have a good approach to my problem. What I need to ask now may seem more silly, but I am not sure how to proceed. I understand how to "insert" into another table using the code you suggested, if I want to "update" the master table and do the insert in the same code, would that be any more difficult...? Here is what I mean
global $conn;

// Update Data in Master Tble

$str = "update TableName set field1=1,field2="hi" where ".$where;

db_exec($str,$conn);
// Now "insert" into Another Table

$str = "select field1,field2 from TableName where ".$where;

$rs = db_query($str,$conn);

$data = db_fetch_aray($rs);

$strSQL="insert into AnotherTableName (FieldName1,FieldName2) values ('".$data["field1"]."','".$data["field2"]."');

db_exec($strSQL,$conn);
What I am asking, do you see any problems with ading those two lines?
Thank You so very much
Mike

M
michaelmac author 6/6/2007

Mike,

the best way to see value of $where variable is to print it on the page:


Thanks Jane.. your example was perfect..
Mike

M
michaelmac author 6/8/2007



Thank you Jane. I am going to implement the code in the morning. I do have a question though, what does the variable $where represent? I mean I am not sure if I assign it some value, or does it have one already.
This solution (I hope) will allow me the ability to solve a couple of issues. The mass mailing and the mass insert from the _list.php page. I still need to know how to enter a "text" box so my user can enter in a value I will write to the table.
Thanks for all you help
Mike


Thanks Jane.. it worked like a champ. Being the perfectionist that I am, I tried to modify it a little to make the "link" fit more with my page.. Now it looks great, but I get an error that the "link" can not find my html page. Here is my modified code from what you originally sent me.
<A

style="TEXT-DECORATION: none" href="previousTitles_list.htm#"

false;? return frmAdmin.submit(); ; frmAdmin.a.value="insert"

false; records??)) these submit to want really you (!confirm(?Do

if><FONT face=Verdana>Submit selected</FONT></A>
Can this be fixed, or do I go back to the original code you gave me?
Thanks so very much for all you guys and gals do for us here in this cyber cafe
Mike

M
michaelmac author 6/11/2007

Hey Guys/Gals...
I did the following per Jane's suggestion.. I modified it just to test it ..
<A onclick="if (!confirm('Do you really want to insert these records?')) return false;

frmAdmin.a.value='insert';

frmAdmin.submit(); return false;"

href="renewals_list.htm#">Insert selected</A>
I get this error now.. I mean it worked on one page.. is there a reason I can not open the renewal_list.htm, I mean can I not use the same code on two separate _list pages... This is the error I get now:
Not Found

The requested URL /Users/renewals_list.htm was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache/1.3.37 Server at www.cardinalsys.com Port 80
Does anyone now why I am unable to see this page from my onclick...??
The REAL POINT of my writing this post...
What I am trying to do is this:
<A onclick="if (!confirm('Do you really want to insert these records?')) return false;

frmAdmin.a.value='insert';

frmAdmin.b.value='TEXT'; <<<---I want to find a way yo have the user input this value, and this pass to renewals_list.htm#?

frmAdmin.submit(); return false;"

href="renewals_list.htm#">Insert selected</A>
I just wanted to say thanks for all your great work...
Thanks in advance..
Mike