if (isset($_GET['id'])) {
// Connect to the MySQL database
include "connect.php";
$id = preg_replace('#[^0-9]#i', '', $_GET['id']);
// Use this var to check to see if this ID exists, if yes then get the bio info
$sql = mysql_query("SELECT * FROM bio\n"
. "LEFT JOIN bio_media \n"
. "ON bio.id=bio_media.bioid\n"
. "WHERE bio.id = ".$id."\n"
. "\n"
. " LIMIT 0, 30 ");
// get all the bio details
while($row = mysql_fetch_array($sql)){
$name = $row["name"];
$age = $row["age"];
$division = $row["division"];
$pic = $row["pic"];
$story = $row["story"];
$fb = $row["fb"];
$tw = $row["tw"];
$type = $row['type'];
$file = $row['file'];
$alt = $row['alt'];
$title = $row['title'];
$Age= DetermineAgeFromDOB ($age);
while ($type == "image"){
$images .='<a rel="lb[pp_gal]" href="images/'.$file.'" ><img width="60px" alt="'.$alt.'" title="'.$title.'" src="images/'.$file.'" /></a>';
break;
}
$i=-1;
if($type == "video"){
$i++;
$videos .='<li><a href="watch.php?id='.$id.'&v='.$file.'&ref='.$i.'?iframe=true&width=745&height=520" rel="lb" title="'.$alt.'">'.$title.'</a></li>';
}
问题:如何获取网址的“ref”部分,以便为数据库中的每个条目更新+1?
答案 0 :(得分:2)
如果我理解正确,你必须摆脱循环中的$i=-1;
,只需将$i=0;
放在循环之前。
顺便说一句,你每次都在覆盖循环中的变量;或者只是将$row
添加到数组并使用它或根本不使用这些临时变量,只需在需要的地方直接使用$row
。