Re: if statement
Thanks people.
I debug, it returns null :/
Means something is wrong in code.
Here is my controller:
<?php
class IndexsController extends AppController {
public $helpers = array('Html', 'Form', 'Session');
public $components = array('Session');
public function index() {
// loading Game model
$this->loadModel('Game');
$game = $this->Game->find('all');
$this->set('games', $this->Game->find('all'));
// loading Word model
$this->loadModel('Word');
$word = $this->Word->find('all');
$this->set('words', $this->Word->find('all'));
}
public function view($id) {
// loading Game model
$this->loadModel('Game');
$game = $this->Game->find('all');
$this->set('games', $this->Game->find('all'));
$dif=$game['Game']['difficulty'];
// loading Word model
$this->loadModel('Word');
$word = $this->Word->find('all');
$this->set('words', $this->Word->find('all'));
$this->Game->id = $id;
$this->set('game', $this->Game->read());
//variables
$this->set('rand', rand(1,$this->Word->find('count')));
$this->set('randword', $this->Word->findById(11));
//$this->set('word_array', str_split(implode("", $this->Word->findById(11)),1));
$this->set('word_array', str_split('fight',1));
$this->set('code', array("*", "*", "*", "*", "*"));
$code=array("*", "*", "*", "*", "*");
for ($i =97; $i<=122; $i++) {
$letter .= "<a href='view.ctp?code=".$code."&var=".chr($i)."&dif=".$dif."'>".chr($i) ."</a>". " ";
$this->set('tar', $letter);
$this->set('popoxakan', $_GET['var']);
$position = 0;
$var_get = $_GET['var'];
$word = $this->Word->findById(11);
if(in_array($var_get, $word ))
{
$position = $this->array_search($var_get,$word);
}
$this->set('position', $position );
}
}
}
?>
And here view
<?php
echo "word= " .$randword['Word']['word']."</br>";
echo $tar."</br>";
echo $popoxakan."</br>";
echo "position= ".$position."</br>";
?>
-- You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home