<table border="1" width="500">
<tbody>
<tr>
<th>ProFileID</th>
<th>CogID</th>
<th>FileValue</th>
<th> Count </th>
<?php
$sql="Select * From idtable"; // Read idtable
$result=mysql_query($sql); // Query sql
$num=mysql_num_rows($result); // Check record
if($num>0){ // If record > 0
$count=1; //
while($recordset=mysql_fetch_assoc($result)){ // loop
?>
<tr>
<td align="center"><?php echo $count; ?></td>
<td><?php echo $cogid = $recordset['CogID']; ?></td>
<td><?php echo $FileValue = $recordset['FileValue']; ?></td>
<td><? $url = "https://s3-ap-southeast-1.amazonaws.com/cloudpoc2/".$cogid."/Contacts/contactsversion3/".$FileValue."";
//example "https://s3-ap-southeast-1.amazonaws.com/cloudpoc2/us-east-1%3Ab9b09e99-5921-494a-b5a7-54f289131eaa/Contacts/contactsversion3/Contacts_1437450598237.txt";
$getText = file_get_contents("$url", true);
$Contact = substr_count($getText ,"FIRSTNAME");
echo $countupdate = $Contact; ?>
</tr>
<?
$count+=1; // Increase count +1
}
}
?>
</tbody>
<?php // UPDATE TO DATABASE
$updatecount = "INSERT INTO counttable (ProfileID,Count,Timestamp)
VALUES('','$countupdate','')";
mysql_query($updatecount);
?>
**我想将计数更新为phpmyadmin 表名是可数的我有2个数据,但它只显示一个数据我不知道发生了什么**有些实物请帮助我
这是我的照片
答案 0 :(得分:1)
在 while
循环结束后进行更新。循环结束后$updatecount
存储$Contact
的最后一个值。如果要在while
循环的每次迭代时更新表,请在循环中移动更新查询:
while($recordset=mysql_fetch_assoc($result)) { // loop
// do something here
$updatecount = "INSERT INTO counttable (ProfileID,Count,Timestamp) VALUES('','$countupdate','')";
mysql_query($updatecount);
}