データは、テーブルから値を取得することによってページ(all.php)に表示されます。ここでの主な問題は、「f5キー」または「リフレッシュアイコン」を使用してページを更新すると、クロムではデータは良好に保たれますが、一度URLを選択して「入力」を押すとデータが消えます。理由は何でしょうか?ページを更新した後にデータが表示されない
<?php
require 'config.php';
if(isset($_POST['all']))
{
$new_obj= new config;
$rows= $new_obj->Get_All();
foreach($rows as $variable => $value){
echo $value['EAN'].$value['ProductCode']."</br>";
}
}
all.php
のindex.php
<form action="all.php" method="post">
<p>Get all the Codes</p>
<input type="submit" name="all" >
</form>
config.phpの
<?php
class config
{
function Get_ALL()
{
try {
$conn = new PDO('mysql:host=localhost;dbname=test',$this->config['username'],$this->config['password']);
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$stmt=$conn->prepare("select EAN,ProductCode from code");
$stmt->execute();
//$rows = $stmt->fetch(PDO::FETCH_ASSOC);
$rows = $stmt->fetchall();
return $rows;
}
catch(PDOException $e)
{
echo 'Error:'. $e->getMessage();
}
}
}
$new_obj= new config;
助けの多くではないかもしれません。 – Cyclonecode
あなたはまずPOSTとGET要求を理解しています。今すぐあなたの問題に来るf5ボタンを押すかリフレッシュブラウザを押すと、POST要求を再度all.phpに送信しますが、あなたがなぜあなたがいないことをGET要求を送信するURLを選択してEnterボタンを押しているデータを取得する。 – Bokul