I have the Code below.
-----------------------star.thtml-----------------------------
<div id="first">
<?php $current=0;
foreach($all['0']['Star'] as $star)
{$current +=$star['star'];}
$num=count($all['0']['Star']);
echo "Have".$num."Peolpe Vote";
$avg=$current/$num*25;
echo " --Total:".$avg;
?>
<ul class='star-rating'>
<li class='current-rating' style='width:<?php echo $avg?>px' ></li>
<li><?php echo $ajax->link('1','/stars/update/1',array('title'=>'one
star','class'=>'one-stars','update' => array('first', 'second')))?>
</li>
... ...
<li><?php echo $ajax->link('5','/stars/update/5',array('title'=>'five
stars','class'=>'five-stars','update' => array('first', 'second')))?>
</li>
</ul>
</div>
-------------------------------------------------------------
-------------------------update.thtml------------------
<?php echo $ajax->div('first'); ?>
<?php $current=0;
foreach($all['0']['Star'] as $star)
{$current +=$star['star'];}
$num=count($all['0']['Star']);
echo "Have".$num."Peolpe Vote";
$avg=$current/$num*25;
echo " --Total:".$avg;
?>
<ul class='star-rating'>
<li class='current-rating' style='width:<?php echo $avg?>px' ></li>
<li><?php echo $ajax->link('1','/stars/update/1',array('title'=>'one
star','class'=>'one-stars','update' => array('first', 'second')))?>
</li>
... ...
<li><?php echo $ajax->link('5','/stars/update/5',array('title'=>'five
stars','class'=>'five-stars','update' => array('first', 'second')))?>
</li>
</ul>
<?php echo $ajax->divEnd('first'); ?>
-----------------------------------------------------------
---------------------stars_controller.php----------
function update($id=null)
{
$user_id= 2;
$good_id=1;
$this->Star->query("INSERT INTO `stars` ( `id` , `star` ,
`user_id`,`good_id` )
VALUES (NULL , $id, $user_id, $good_id)");
$this->set('all',$this->requestAction('/goods/getStar/'));
$this->layout= 'ajax';
}
------------------------------------------------------------
NOW, I pass the stars through $id via Ajax store it into DB, and it
works well.
BUT, how can I pass the $good_id for a certain good/product.
One situation like goods/view/1, I think I can get the $good_id
through $this->parmas['url']. And the user_id by session.
But If a page contains several other goods/product. How can I star
them and save it?
Which means I wanna pass a $good_id from the view.thtml to the
controller. It seems wrong. But How can I make it?
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---