Forums

CC sintaxis

nivato 03 May, 2010
Im created this code in Dreamweaver:

<?php require_once('Connections/aa.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_aa, $aa);
$query_Recordset1 = "SELECT * FROM jos_rstickets_tickets";
$Recordset1 = mysql_query($query_Recordset1, $aa) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_aa, $aa);
$query_Recordset2 = "SELECT TicketStatus FROM jos_rstickets_tickets WHERE TicketStatus = 'imputada'";
$Recordset2 = mysql_query($query_Recordset2, $aa) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

mysql_select_db($database_aa, $aa);
$query_Recordset3 = "SELECT TicketStatus FROM jos_rstickets_tickets WHERE TicketStatus = 'open'";
$Recordset3 = mysql_query($query_Recordset3, $aa) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);

mysql_select_db($database_aa, $aa);
$query_Recordset4 = "SELECT TicketStatus FROM jos_rstickets_tickets WHERE TicketStatus = 'on-hold'";
$Recordset4 = mysql_query($query_Recordset4, $aa) or die(mysql_error());
$row_Recordset4 = mysql_fetch_assoc($Recordset4);
$totalRows_Recordset4 = mysql_num_rows($Recordset4);

mysql_select_db($database_aa, $aa);
$query_Recordset5 = "SELECT TicketStatus FROM jos_rstickets_tickets WHERE TicketStatus = 'pagadas'";
$Recordset5 = mysql_query($query_Recordset5, $aa) or die(mysql_error());
$row_Recordset5 = mysql_fetch_assoc($Recordset5);
$totalRows_Recordset5 = mysql_num_rows($Recordset5);

mysql_select_db($database_aa, $aa);
$query_Recordset6 = "SELECT TicketStatus FROM jos_rstickets_tickets WHERE TicketStatus = 'cerrada'";
$Recordset6 = mysql_query($query_Recordset6, $aa) or die(mysql_error());
$row_Recordset6 = mysql_fetch_assoc($Recordset6);
$totalRows_Recordset6 = mysql_num_rows($Recordset6);

mysql_select_db($database_aa, $aa);
$query_Recordset7 = "SELECT TicketStatus, Producto FROM jos_rstickets_tickets WHERE TicketStatus = 'imputada' AND jos_rstickets_tickets.Producto = 'Otro'";
$Recordset7 = mysql_query($query_Recordset7, $aa) or die(mysql_error());
$row_Recordset7 = mysql_fetch_assoc($Recordset7);
$totalRows_Recordset7 = mysql_num_rows($Recordset7);

mysql_select_db($database_aa, $aa);
$query_Recordset8 = "SELECT TicketStatus, Producto FROM jos_rstickets_tickets WHERE TicketStatus = 'imputada' AND jos_rstickets_tickets.Producto = 'Linea'";
$Recordset8 = mysql_query($query_Recordset8, $aa) or die(mysql_error());
$row_Recordset8 = mysql_fetch_assoc($Recordset8);
$totalRows_Recordset8 = mysql_num_rows($Recordset8);

mysql_select_db($database_aa, $aa);
$query_Recordset9 = "SELECT TicketStatus, Producto FROM jos_rstickets_tickets WHERE TicketStatus = 'imputada' AND jos_rstickets_tickets.Producto = 'Linea+Internet'";
$Recordset9 = mysql_query($query_Recordset9, $aa) or die(mysql_error());
$row_Recordset9 = mysql_fetch_assoc($Recordset9);
$totalRows_Recordset9 = mysql_num_rows($Recordset9);


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>

<body>
Usted tiene un total de <?php echo $totalRows_Recordset1 ?> preventas ingresadas en el sistema
<p>
Preventas abiertas: <?php echo $totalRows_Recordset3 ?>
<p>
Preventas informadas: <?php echo $totalRows_Recordset4 ?>
<p>
Preventas imputadas: <?php echo $totalRows_Recordset2 ?>
<p>
Preventas pagadas: <?php echo $totalRows_Recordset5 ?>
<p>
Preventas cerradas: <?php echo $totalRows_Recordset5 ?>
<p>
PREVENTAS IMPUTADAS POR PRODUCTO (PAGADERAS 15 DEL MES QUE VIENE SI EL TOTAL SUMA $100 O MAS)
<p>
Otros productos: <?php echo $totalRows_Recordset7 ?>
<p>
Lineas: <?php echo $totalRows_Recordset8 ?> = <?php echo $totalRows_Recordset8 * 975 / 100 ?> $ (pesos)
<p>
Linea + Internet: <?php echo $totalRows_Recordset9 ?>
<p>
PREVENTAS YA PAGADAS
<p>
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($Recordset2);

mysql_free_result($Recordset6);

mysql_free_result($Recordset7);

mysql_free_result($Recordset9);

mysql_free_result($Recordset8);

mysql_free_result($Recordset3);

mysql_free_result($Recordset4);

mysql_free_result($Recordset5);
?>



Is there any chance to clonate this working coding using chorononectivity, because Im really stuck in this and I need to implement to run my joomla site. If anibody can help me with the translation... please
nivato 03 May, 2010
Its me again, sorry for the pain, Im triying to solve the issue but....

In WHERE SQL BOX I HAVE:
<?php
$user = &JFactory::getUser();
echo " WHERE CustomerId = ".$user->id 
?>


And works: the cc frontend view shows only the records that match with the CustomerId and Joomla login have in both tables.

But if I try to add another WHERE command with or without the AND command, the 1rst WHERE command stop and the cc page start to display all database records againg.

Example 1:
<?php
$user = &JFactory::getUser();
echo " WHERE CustomerID = ".$user->id 
echo " WHERE TicketStatus = "imputada 
?>


Not working

Example 2:
<?php
$user = &JFactory::getUser();
echo " WHERE CustomerID = ".$user->id 
echo " AND TicketStatus = "imputada 
?>


Not working

Example 3:
<?php
$user = &JFactory::getUser();
echo " WHERE CustomerID = ".$user->id AND TicketStatus = "imputada 
?>


If somebody can help me to make that cc page show not only the data taking only the records that belong to the logged user but count each column based records like in my dreamweaver page, tha will be very appretiated. At this point you can ask me why I dont use the dreamweaver script embbeded in a joomla page: that´s because the dw script doesnt have joomla string connection and I dont know how to include the variable of user login=CustomerId to work with Joomla enviroment.

..or at least give the name of the operations Im triying to do...

THANKS AGAIN
GreyHead 08 May, 2010
Hi nivato,

You can't usefully echo more that one WHERE line. It has to be
WHERE condion_a AND condition_b AND . . .
In your case you need to have
echo " WHERE `CustomerID` = $user->id
  AND `TicketStatus` = 'imputada' "; 

Bob
fabaya 09 May, 2010
GREYHEAD if you ever come to Mendoza, Argentina for example to visit the Aconcagua... you have a dinner and a good bottle of wine (Mendoza is wordlwide famous for winery) for sure. Thanks man to take some of your time for giving help to the forum members everyday.
This topic is locked and no more replies can be posted.