Mercurial > hg > ywww
diff php/read/updateLink.php @ 6:077b0a0a3e6d
remaining originals according to dependency walk
author | Robert Boland <robert@markup.co.uk> |
---|---|
date | Thu, 16 Feb 2017 22:29:02 +0000 |
parents | |
children | 385ddd7c4b55 84a412b8122c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/php/read/updateLink.php Thu Feb 16 22:29:02 2017 +0000 @@ -0,0 +1,77 @@ +<?PHP + +$linkID = strval($_GET['linkID']); +echo $linkID; +$change = strval($_GET['change']); +echo $change; +$dir = strval($_GET['dir']); +echo $dir; +$userID = strval($_GET['userID']); +echo $userID; + +include "../../../private/db.php"; + +$pos = 0; +$neg = 0; + +if($change == "pos") +{ + if($dir == "pos") + { + $state = 1; + $pos = 1; + } + else + { + $state = 0; + $pos = -1; + } +} +else +{ + if($dir == "pos") + { + $state = -1; + $neg = 1; + } + else + { + $state = 0; + $neg = -1; + } +} + +if($userID == "") +{ + $updateQuery = 'CALL b_changeLink('. $linkID . ',' . $pos .',0,' . $neg .',0)'; + echo $updateQuery; + $dataFinal = mysqli_query($link, $updateQuery); +} +else +{ + $check = 'CALL b_getStateID('. $userID .','. $linkID .')'; //select StateID from thumbstate where UserID = ' . $userID . ' and linkID = ' . $linkID; + echo $check; + $result = mysqli_query($link, $check) or exit( mysqli_error( $link )); + $count=mysqli_num_rows($result); + if($count==1){ + $rows=mysqli_fetch_array($result, MYSQLI_ASSOC); + $stateID=$rows['StateID']; + $stateQuery = "CALL b_updateThumbState($stateID,$state)"; + } + else + { + $stateQuery = "CALL b_insertThumbState($userID,$linkID,$state)"; + } + echo $stateQuery; + + mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop + include "../../../private/db.php"; + $stateFinal = mysqli_query($link, $stateQuery) or exit( mysqli_error( $link )); +} + +//if email not zero, select userid from user where email=email +//insert into thumbstate null,userid,linkid,state (1,0,-1) + +mysqli_close($link); + +?> \ No newline at end of file