i'm retrieving a record from database. below the record, i have a yes and no button, where i can let user click and then count the number of yes and no.
everything works fine, but when i start to click the yes or no button, my record ,becomes two records. i only have one record in my database, but two same record was displayed.
this is the code:
pls help. thanks.PHP Code:function admin_view($cat_ID)
{
global $review_obj, $cat, $subcat, $title, $flag, $desc, $image, $cat_ID, $cate, $subcate, $newrows;
global $url_site, $url_image, $font_face, $font_color;
//**********************Retrieve data from admin_review********************
$result = mysql_query("SELECT ID, date, cat, rate, title, review, flag, cat_ID, mod_ID, status FROM review WHERE flag=1 AND status='a' AND cat_ID='$cat_ID' ORDER BY date DESC");
$numrows = mysql_num_rows($result);
//***************************view admin_review*******************************
if ($numrows > 0)
{
//echo "<tr><td>";
echo"<table width=100% border=0 cellpadding=1 cellspacing=1>";
echo "<tr><td><font face=\"$font_face\" size=2 color=\"$font_color\"><b>Administrator's Review</b></font></td></tr>";
}else
$rows=0;
while ($temp = mysql_fetch_array($result))
{
$date = display_date($temp['date']);
$ID = $temp['ID'];
$cat = $temp['cat'];
$star = $temp['rate'];
$title = $temp['title'];
$review = $temp['review'];
$cat_ID = $temp['cat_ID'];
$mod_ID = $temp['mod_ID'];
$status = $temp['status'];
$yes = count_review('a',$ID,'y');
$no = count_review('a',$ID,'n');
if ($yes == '')
$yes = 0;
if ($no == '')
$no = 0;
$total = $yes + $no;
if ($total != 0)
{
echo "<tr><td><font face=\"$font_face\" size=1>$yes of $total people found the following review helpful:</font></td></tr>";
}
echo "<tr><td>";
display_star($star);
echo "<font face=\"$font_face\" size=1><b> $title,</b></font><font face=\"$font_face\" size=1> $date</font></td></tr>";
echo "<tr><td><font face=\"$font_face\" size=1> ";
$word = explode(" ", $review);
$number = 0;
$row = 0;
$flat = 0;
$newrow=0;
for ($j=0;$j<count($word) ;$j++)
{
$number += strlen($word[$j]);
if ($j == 0 || $newrows == 1)
echo $word[$j];
else
{
echo " ".$word[$j];
$newrows = 0;
}
if ($number > 58)
{
echo "<br>";
echo " ";
$number = 0;
$row++;
$newrow = 1;
}
if ($row == 10)
{
$flat = 1;
break;
}
}
if ($flat)
{
echo "<font face=\"$font_face\" size=1>...<a href=\"$url_site/template/index.php?ID=$ID&cat=$cat&title=$title&review=$review&image=$image&flag=$flag&status=a&a=1\">more details</a></font>";
}
echo "</font></td></tr>";
echo "<tr><td> </td></tr>";
echo "<tr><td><font face=\"$font_face\" size=1>Do you find this review useful: ";
echo "<a href=\"$url_site/template/index.php?ID=$ID&status=a&cflag=y&image=$imgpath&cat_cat=$cat&title=$title&review=$review&cat_ID=$cat_ID\"><img src='$url_image/template/image/yes.gif' border=0 align=middle></a> ";
echo "<a href=\"$url_site/template/index.php?ID=$ID&status=a&cflag=n&image=$imgpath&cat_cat=$cat&title=$title&review=$review&cat_ID=$cat_ID\"><img src='$url_image/template/image/no.gif' border=0 align=middle></a>";
echo "</td></tr>";
} //endfor
if ($numrows > 0)
{
echo "</td></tr>";
echo "</table>";
}
}




Bookmarks