Jump to content

PHP Help - SELECT, INSERT, UPDATE


jason1987

Recommended Posts

hello, if anyone can help would be great

 

On this project I have got 2 items a mobile and simcard, these are in one table as two records and have a unique equid each. the simcard is also in another table called siminfo and has a parentid (which is the same equid as the mobile) to create the link. In the equipment table there is also userid

 

I already have code that transfers these items individually, but i want to be able to transfer them both when i transfer the sim card. I currently have the followin but its not working for some reason. the variable $equid does work i have tested it. This code is not picking up the simparentid though

 

[$simlink = "SELECT simparentid FROM itsiminfo WHERE itequip.equid = '$equid'";        
$ressimlink = mysql_query($simlink)
$querytransins2 = " INSERT INTO itequiptransfers (equid, fromuserid, touserid) VALUES ('".$ressimlink."', '".$fromuserid."', '".$touserid."')";
$resulttransins2 = mysql_query($querytransins2);
equins2 = "UPDATE itequip SET equuser='$touserid' WHERE equuser='$fromuserid' AND equid= '$ressimlink'";
$resultequins2 = mysql_query($equins2);

Link to comment
https://forums.phpfreaks.com/topic/73326-php-help-select-insert-update/
Share on other sites

I need to have them seperate because a user can have just a sim card or just a mobile

 

I have changed it as follows but still not working :s

$simlink = "SELECT simparentid FROM itsiminfo WHERE itequip.equid = '$equid' ";		 // for sim 
$ressimlink = mysql_fetch_assoc($simlink);
$querytransins2 = " INSERT INTO itequiptransfers (equid, fromuserid, touserid) VALUES ('".$ressimlink."', '".$fromuserid."', '".$touserid."')";
  	$resulttransins2 = mysql_query($querytransins2);
    $equins2 = "UPDATE itequip SET equuser='$touserid' WHERE equuser='$fromuserid' AND equid= '$ressimlink'";
    $resultequins2 = mysql_query($equins2);   

Archived

This topic is now archived and is closed to further replies.

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