我以为我会发布现在正在运行的完整代码。感谢所有回答我问题的人,非常感谢。成为这个社区的一员非常敏感。
我的代码是:
mysql_connect("localhost", "username", "password")or die("cannot connect");
mysql_select_db("dbname")or die("cannot select DB");
$sql="SELECT `dispatcharea`,`customer`,`casenumber`,`weight` from loaddetails where loadid = 0 order by dispatcharea";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
Plan Local PMB Delivery - Step 2
Load Number |
Number of Cases |
Load Weight |
Other Detail |
$loadid = mysql_query('SELECT max(loadid)+1 FROM loaddetails'); if (!$loadid) { die('Could not query:' . mysql_error()); } echo mysql_result($loadid, 0); ?> |
$nocases = mysql_query('SELECT count(*) FROM loaddetails where loadid = 0'); if (!$nocases) { die('Could not query:' . mysql_error()); } echo mysql_result($nocases, 0); ?> |
$weight = mysql_query('SELECT SUM(WEIGHT) FROM loaddetails where loadid = 0'); if (!$loadid) { die('Could not query:' . mysql_error()); } echo mysql_result($weight, 0); ?> |
|
while($rows=mysql_fetch_array($result)){ ?> | ||||
<?php echo $rows['dispatcharea']; ?> | <?php echo $rows['customer']; ?> | <?php echo $rows['casenumber']; ?> | <?php echo $rows['weight']; ?> |
}
?>
// First update query
$sql1="update loaddetails set loadid= (select max(loadid)+1 from loadcounterid) where loadid=0";
// Second update query
$sql2="update loadcounterid set loadid= (select max(loadid) from loaddetails) where loadid>0";
if($_REQUEST['Next']=='Next'){
// Run both queries independently
$final_query1 = mysql_query($sql1);
$final_query2 = mysql_query($sql2);
if ($final_query1 && $final_query2)
{
// Success running the queries
echo "";
}
else
{
// Unsuccessful running the queries
}
}
?>