loveblue Posted April 1, 2009 Share Posted April 1, 2009 hai .... I need help ..... I have a database table "device" and "event". column table "device" content "account" and "dev_id". while in table "event" content "account", "dev_id" and "event". table in the "device" I have the following data: "account" "dev_id" demo red_car demo blue_car admin red_car I want to insert data to table "event". if there is data entry with "dev_id" blue_car, the data insert to the table there are no problems. the problem appears when there is equality that is "dev_id" red_car because both dev_id are owned by the demo and admin accounts. I want to ask for assistance on how to enter data to the table "event" occurs when conditions such as the above there are similarities "dev_id" red_car. so that data entered is complete all that is "account" "dev_id" "event" demo red_car stop admin red_car stop here is my php <? //conn1-------------------------------------------------------------------------------------------------------- $host1="localhost"; $user1="root"; $pass1="cipluk"; $conn1 = mysql_connect("$host1","$user1","$pass1"); mysql_select_db("gts", $conn1); $query_id = "select account from device where dev_id = '$vehicle_id'"; $jawab = mysql_query($query_id,$conn1); while ($row_id = mysql_fetch_array($jawab)) { $accid = $row_id['account']; } //insert---------------------------------------------------------------------- $sql = "INSERT INTO event(account,dev_id,event) VALUES ("; $sql .= "'". addslashes($accid) . "'"; $sql .= ",'" . addslashes($vehicle_id) . "'"; $sql .= ",'" . addslashes($event) . "'"; $sql .= ");"; echo "Data insertion \r\n".$sql; mysql_query($sql,$conn1); thankyou verry much really need help Quote Link to comment https://forums.phpfreaks.com/topic/152080-need-help-entry-database-using-php-and-mysql/ Share on other sites More sharing options...
JeanieTallis Posted April 1, 2009 Share Posted April 1, 2009 It all depends how your inserting the values into the database. Button, Page Refresh Form (linking to a button I guess) Also, I do advise you to not put real database passwords and usernames. Also, I don't see your database name? Quote Link to comment https://forums.phpfreaks.com/topic/152080-need-help-entry-database-using-php-and-mysql/#findComment-798690 Share on other sites More sharing options...
loveblue Posted April 2, 2009 Author Share Posted April 2, 2009 It all depends how your inserting the values into the database. Button, Page Refresh Form (linking to a button I guess) Also, I do advise you to not put real database passwords and usernames. Also, I don't see your database name? thanks for the reply...... the database name is gts... I use php socket to receive the data. data processed and entered into the database. at the time of entering into the database that what I want to ask. when data is selected in the query there are 2 or more how to enter the database. $query_id = "select account from device where dev_id = '$vehicle_id'"; here is what i'v got from the dump string(52) "select account from device where dev_id = 'red_car'" string(5) "admin" string(4) "demo" Data insertion INSERT INTO event(account,dev_id,event) VALUES ('demo','red_car','stop') only one data inserted....account demo. i need admin account is inserted to with data Quote Link to comment https://forums.phpfreaks.com/topic/152080-need-help-entry-database-using-php-and-mysql/#findComment-799141 Share on other sites More sharing options...
loveblue Posted April 2, 2009 Author Share Posted April 2, 2009 is there any one who knows Quote Link to comment https://forums.phpfreaks.com/topic/152080-need-help-entry-database-using-php-and-mysql/#findComment-799546 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.