i have been trying check if selected row last in mysql data records, if last go first record. here have done far:
$fps = @fopen('number.txt', "r+"); $somay = fread($fps, filesize('number.txt')); fclose($fps); $num = ($somay+1); $file = "number.txt"; $fh = fopen($file,'w+') or die("cant open file"); fwrite($fh,$num); fclose($fh); $sql = "select @last_id := max(id),token `token` `id` = '".$somay."'"; if (!$result = $mysqli->query($sql)) { echo "sorry, website experiencing problems."; echo "error: our query failed execute , here why: \n"; echo "query: " . $sql . "\n"; echo "errno: " . $mysqli->errno . "\n"; echo "error: " . $mysqli->error . "\n"; exit; } if ($result->num_rows === 0) { echo "we not find match id, sorry that. please try again."; exit; } while ($tokennek = $result->fetch_assoc()) { $token = $tokennek[token]; $tokenid = $tokennek[last_id]; } if($somay == $tokenid){ $file = "number.txt"; $fh = fopen($file,'w+') or die("cant open file"); fwrite($fh,1); fclose($fh); }
let me make more clear here doing saving file named number.txt keep record of token been used , go next token/row.
Comments
Post a Comment