CF & CC

mja1356 09 Mar, 2009
Hi
I use CF to retrieve data from database and put them in a html table.becouse records are too much i need some kind of pagination.I fouond that i can use CC to paginate long sheets but there is some problem.I want to CC retrive data that correspond to user id that i send via get(in url) but it doesn't work.do lot nu, do lot cao cap, do boi nam, do so sinh tron goi, do so sinh cao cap cho be, quan ao so sinh cao cap, chan vay cong so, ao so mi cong so, ban buon quan ao, do lot[/url]
i created a link like this (the last line:


<?php
//connet to MySQL server
$db = mysql_connect("localhost", "test1", "123456");
mysql_select_db('test');
$user =& JFactory::getUser();
$userId = $user->get( 'id' );
$query="select cb_credit from jos_comprofiler where user_id='$userId'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
echo "اعتبار شما :.$row[0] تومان";echo "<br>";
echo "<a href='index.php?option=com_user&view=user&task=edit&Itemid=20'>جزييات حساب کاربري</a>";echo "<br>";
echo "<a href='index.php?option=com_chronoconnectivity&connectionname=all&userId=$userId'>تاريخچه</a>";
?>



what do i do whit CC.
GreyHead 09 Mar, 2009
Hi mja1356,

Fisrt, you can simplify your code a little by using some Joomal 1.5 standard methods.
<?php
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$userId = $user->id;
$query="
  SELECT `cb_credit` FROM `#__comprofiler` WHERE `user_id` = '$userId' ";
$db->setQuery($query);
$t_row = $db->loadResultArray();
echo "اعتبار شما :.$t_row[0] تومان";echo "<br>";
echo "<a href='index.php?option=com_user&view=user&task=edit&Itemid=20'>جزييات حساب کاربري</a>";echo "<br>";
echo "<a href='index.php?option=com_chronoconnectivity&connectionname=all&userId=$userId'>تاريخچه</a>";
?>

In the ChronoConnectivity Where box you'll need to get this value back from the url
<?php
$userId = JRequest::getInt('userId', '', 'get');
echo "WHERE `userid` = '$userId`"; // make this the WHERE clause that you need
?>

Bob

PS Actually you can look the **current** User ID up in the Where box just as easily as pass it in a url
mja1356 09 Mar, 2009
Hi

now i have two error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '65`' at line 1 SQL=SELECT count(*) FROM jos_chronoforms_6 `userid` = '65

and


Warning: Invalid argument supplied for foreach() in C:\wamp\www\joomla\components\com_chronoconnectivity\chronoconnectivity.html.php on line 172

what does that mean?
GreyHead 09 Mar, 2009
Hi mja1365,

Check the quotes in my SQL especially round WHERE `user_id` = '$userId' "; there should be two straight single quotes round the $userid.

Bob
mja1356 09 Mar, 2009
I'm sorry maybe this is very simple but i don't know where should i put where clause?

I must put this code in where BOX?
<?php
    $userId = JRequest::getInt('userId', '', 'get');
    echo "`userid` = '$userId'";
		// make this the WHERE clause that you need
    ?>

but what about where clause?
I must put where userid=$userId inside php code?
because i can't see select I don't know where i put where clause
GreyHead 09 Mar, 2009
Hi mja1356,

Sorry, I missed the WHERE out of my post - corrected now. I coulnd't remermber if it was needed or not and I got it wrong :-(

Bob
mja1356 09 Mar, 2009
thanks
i used this code and it works.
where userid='<?php
    $userId = JRequest::getInt('userId', '', 'get');
	echo "$userId";
	?>'
mja1356 09 Mar, 2009
Hello again

I have a question about use php code in body box in CC.
look at this code
<P><tr dir='ltr'><td>{betcode}</td><td>{branch}</td><td>{cat}</td><td>{recordtime}</td><td>{game}</td><td>
<?php
    $db =& JFactory::getDBO();
    
    $query="SELECT * FROM jos_chronoforms_6 ";
    $result = mysql_query($query);
    $num = mysql_num_rows($result);
    for($i = 0; $i < $num; $i ++)
	{
	  	$row = mysql_fetch_row($result);
	
	$x=$row[15];
	
	if ($x==1)

	echo "{host}";
	else
	echo "{guest}";
	}
	?>
</td><td>{win}</td>
<td>{loss}</td><td>{line}</td><td>{odd}</td><td>
<?php
    
	$y=$row[9];
	if ($y=='بازي کامل')
	echo "{ftga}{gtgb}";
	else
	echo "{htga}{htgb}";
	
	?>
</td>
</tr></p>


what's wrong with it?
when i use this this error appears:
Trying to get property of non-object

how can i use conditional php code inside body box?

thanks
GreyHead 09 Mar, 2009
Hi mja13256,

You can't currently use $row or $rows in your PHP here - ChronoForms also uses them and when you re-define it gets confused.

Try replacing them with $t_rows & $t_row and I think it will work OK.

You may also need to switch to Joomla db code which would look like this - however there is something wrong with the placement of the for loop; perhaps it should go round the whole <tr>?
<tr dir='ltr'>
  <td>{betcode}</td>
  <td>{branch}</td>
  <td>{cat}</td>
  <td>{recordtime}</td>
  <td>{game}</td>
  <td>
<?php
    $db =& JFactory::getDBO();
    $query="SELECT * FROM jos_chronoforms_6 ";
    $db->setQuery($query);
    $t_rows = $db->loadResultArray();
    foreach ( $t_rows as $t_row ) {
      if ( $t_row[15] == 1 ) {
        echo "{host}";
      } else {
        echo "{guest}";
      }
   }
?>
  </td>
  <td>{win}</td>
  <td>{loss}</td>
  <td>{line}</td>
  <td>{odd}</td>
  <td>
<?php
      if ( $t_row[9] == 'بازي کامل' ) {
        echo "{ftga}{gtgb}";
      } else {
        echo "{htga}{htgb}";
     }
?>
  </td>
</tr>

Bob
This topic is locked and no more replies can be posted.