我解決了我的問題,如dis ...謝謝你的幫助。
路由路徑:
<?php
//divide route path
echo "<br>" .$route_path."</br>";
$hop = explode(">",$route_path);
$hop_count = count($hop)-1;
//maximum number of path columns in the database
$maxPath=9;
$lastIndex = 0;
for($i=0; $i<=$maxPath; $i++)
{
if($i<=$hop_count)
{
$path[$i] = $hop[$i];
$lastIndex = $i;
}
else
{
$path[$i] = null;
}
}
$path[$lastIndex+1] = $router_name;
for($i=1; $i<=$maxPath; $i++)
{
if($path[$i] != NULL)
{
$hop_route[$i-1] = $path[$i-1].'>'.$path[$i];
echo $hop_route[$i-1].'<br/>';
}
else
{
$hop_route[$i-1] = NULL;
}
}
//inserting into database
$sql1 = "INSERT INTO hop (hop_id, hop_1_route, hop_2_route, hop_3_route, hop_4_route, hop_5_route, hop_6_route, hop_7_route, hop_8_route, hop_9_route, hop_count, site_name) VALUES ('', '".$hop_route[0]."', '".$hop_route[1]."', '".$hop_route[2]."', '".$hop_route[3]."', '".$hop_route[4]."', '".$hop_route[5]."', '".$hop_route[6]."', '".$hop_route[7]."', '".$hop_route[8]."', '".$hop_count."', '".$site_name."')";
if ($conn->query($sql1) === TRUE)
{
//echo "New record created successfully";
}
else
{
echo "Error: " . $sql1 . "<br>" . $conn->error;
}
谷歌: 「MySQL的動態支點」。 –