我正在努力獲取以下代碼塊以將數(shù)組變量“行”發(fā)送到另一個(gè)頁(yè)面。另一個(gè)頁(yè)面應(yīng)該從該數(shù)組中提取 vendor_id 并幫助使用數(shù)據(jù)庫(kù)信息填充表單。我完全不知道如何實(shí)現(xiàn)這一點(diǎn),因?yàn)槲覍?duì) Web 開發(fā)相對(duì)較新。有人可以指出我正確的方向嗎? function operateFormatter(value, row, index) { return [ '<a class="remove" href="javascript:void(0)" title="Remove">', '<i class="fa fa-trash"></i>', '</a>', '<a class="view" href="viewVendor.php" title="View">', '<i class="fa fa-eye"></i>', '</a>' ].join('') } window.operateEvents = { 'click .view': function (e, value, row, index) { sessionStorage.setItem("vendor_id", JSON.stringify(row)); }, 'click .remove': function (e, value, row, index) { $table.bootstrapTable('remove', { field: 'id', values: [row.id] }) } }viewVendor.php<?phpinclude 'config.php';require './db_inc.php';$user = $_SESSION['username'];## Fetch records$stmt = $conn->prepare("SELECT * FROM vendor_data");$stmt->execute();$Records = $stmt->fetchAll();$data = array();foreach($Records as $row){ $data[] = array( "name"=>$row['name'], "company"=>$row['company'], "type"=>$row['type'], "status"=>$row['status'], "owner"=>$row['owner'], "descr"=>$row['descr'], "owner_email"=>$row['owner_email'], "dept"=>$row['dept'] );}return json_encode(($data));?><script>alert(sessionStorage.getItem("vendor_id[1]"));</script>我有一個(gè)包含上述 viewVendor.php 文件的 php 頁(yè)面,該文件應(yīng)該傳遞信息。也許我把事情復(fù)雜化了?
獲取要傳遞給php表單的變量
蝴蝶不菲
2022-10-14 10:10:59