This topic is locked

inserting into different tables

6/25/2006 6:29:22 PM
PHPRunner General questions
A
amirgulamali author

Hi,

PHPRunner is an awesome production.. keep it up Xlinesoft!
I need omse help here, everyone is welocme to help.
I have 4 tables;

Artist, Rock, Pop, R&B
I want to enter new artists into the right table, for example Michael Jackson would be inserted in pop <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=2856&image=1&table=forumtopics' class='bbc_emoticon' alt=':lol:' /> , can PHPRunner insert records into different tables from the same ADD PAGE? if yes, HOW???
Thank you

Alexey admin 6/26/2006

Amir,
sure, you can do this modifying the following snippet in generated ..._add.php file.

See my changes in bold.

if(substr($strFields,-2)==", ")

$strFields=substr($strFields,0,strlen($strFields)-2);

if(substr($strValues,-2)==", ")

$strValues=substr($strValues,0,strlen($strValues)-2);

if($values["Singer"]=="'Michael Jackson '")

$strSQL = "insert into pop ";


$strSQL.=$strFields.") values ".$strValues.")";

A
amirgulamali author 6/26/2006

thanx alexa,
Can I have a drop down menu listing the tables as categories adn letting the user decide where to enter the entry, for any entry, not only MJ
thanx again

Alexey admin 6/26/2006

Amir,
sure, just open the ..._add.php file in the text editor, add a dropdown. Then put the code to handle it instead of my "Michael Jackson" snippet.
Here is the sample dropdown:

<select name="genre">

<option value="rock">Rock</option>

<option value="pop">Pop</option>

...

</select>



Here is the code handler:

if($_POST["genre"]=="rock")

$strSQL = "insert into rock ";

else if($_POST["genre"]=="pop")

$strSQL = "insert into pop ";

...

A
amirgulamalil 6/26/2006
A
amirgulamalil 6/26/2006

this maybe a dummm question, im still a newbie:
what feilds from _add.php would be inserted into the table "pop" or "rock"

suppose my rock and pop tables have different feilds. say one has a birthdate feild, while the other has a text feild.

A
amirgulamalil 6/26/2006

i think i saw that feature in events!

cheers

A
amirgulamali author 6/26/2006

in the events:

function AfterAdd()

{

//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into TableName (Field1, Field2) values (Value1, Value2)";

db_exec($strSQLInsert,$conn);
}


what does value 1 and value 2 mean? waht if i want to pass fields to fields between tables...?

A
amirgulamali author 6/26/2006

can anybody pls clarify that?

I want to pass a feild into a feild.

i guess value 1 and value 2 would be hardcoded?

Alexey admin 6/27/2006

Amir,
to manage values being inserted into database

I recommend you to use Before record added event and manipulate $values array there.