我正在嘗試使用jQuery和Chrome的用戶(hù)代理切換器將數(shù)據(jù)插入phpMyAdmin。我修改了此示例中給出的代碼:https://www.w3schools.com/php/php_mysql_insert.asp當(dāng)我打開(kāi)文件時(shí),此數(shù)據(jù)將導(dǎo)入到數(shù)據(jù)庫(kù)中(索引.php)。索引.php<script type="text/javascript"> if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { $('body').addClass('mobile'); <?php $db = mysqli_connect(localhost,root,root,hospital) or die ("Opps, Some thing went wrong!"); $today = date('Y-m-d'); mysqli_query($db,"INSERT INTO `view` (`id`, `date`, `device`) VALUES (NULL, '$today', 'mobile' )" ); ?> } else { <?php $today = date('Y-m-d'); mysqli_query($db,"INSERT INTO `view` (`id`, `date`, `device`) VALUES (NULL, '$today', 'desktop' )" ); ?> } </script>phpMyAdmin----------------------------|id | date | device |----------------------------|1 | 2020-01-15 | mobile ||2 | 2020-01-15 | desktop |----------------------------此數(shù)據(jù)被錯(cuò)誤地發(fā)送到 phpMyAdmin。它將兩個(gè)設(shè)備(移動(dòng)設(shè)備和桌面設(shè)備)導(dǎo)入phpMyAdmin,并且您建議使用什么代碼來(lái)輸出上述相同代碼的設(shè)備?
如何在javascript中將數(shù)據(jù)導(dǎo)入數(shù)據(jù)庫(kù)和phpMyAdmin
阿波羅的戰(zhàn)車(chē)
2022-08-05 10:44:41