fabzster 0 Light Poster

Hi

I am using razorflow chart software to create a dashboard, this works perfectly on my dev server(Locally) but when I upload it to hosted server(Web) it does not load properly.
https://www.razorflow.com/

I get the following errors:

value is not a number
Uncaught TypeError: Cannot read property 'split' of undefined
value is not a number
Uncaught TypeError: Cannot read property 'split' of undefined
value is not a number
Uncaught TypeError: Cannot read property 'split' of undefined
value is not a number
Uncaught TypeError: Cannot read property 'split' of undefined
Uncaught TypeError: e(...).find(...).addBack is not a function
Uncaught TypeError: e(...).find(...).addBack is not a function
Uncaught TypeError: e(...).find(...).addBack is not a function
Uncaught TypeError: e(...).find(...).addBack is not a function
Uncaught TypeError: e(...).find(...).addBack is not a function
Uncaught TypeError: e(...).find(...).addBack is not a function
Uncaught TypeError: e(...).find(...).addBack is not a function
Uncaught TypeError: e(...).find(...).addBack is not a function

What I dont understand is that it works perfectly locally, maybe something to note is that the "Live" server is HTTPS

fabzster 0 Light Poster

i havnt used dompdf as yet but I have setup ezpdf to print out what I need.

I was just wondering if i took an html page that had inputs that were populated by php code if they would display in the converted pdf

fabzster 0 Light Poster

yes but there is php code in them printing variables

<input name="Title" type="text" id="Title" tabindex=2 style="color: <?php print $TextColour;?>;" value="<?php print $_SESSION['Title'] ;?>" size="30" readonly/>
fabzster 0 Light Poster

Hi

Many thanks for the replies, Currently the values sit in variables that are printed in HTML inputs. If I use something to convert the html to PDF then wouldnt I lose the data in the inputs

fabzster 0 Light Poster

Hi

I have a php file with html forms and variables in php.

I generate a policy document that is displayed in the web page and is then created in PDF and emailed to the client.
I create the PSF via using EZPDF but This runs slow when creating the policy and whenever we have to make changes to the document it becomes a huge mission as each element of the PDF file has to be drawn on X and Y coordinates.

Is there a way that I could print this what is displayed on the web page directly to a PDF?

I have added a little excerpt from my current method below:

HTML File Displayed

<table>
        <tr>
            <td class="<?php print $Title_error;?>">Title</td>
            <td><input name="Title" type="text" id="Title" tabindex=2 style="color: <?php print $TextColour;?>;" value="<?php print $_SESSION['Title'] ;?>" size="30" readonly/></td>

            <td class="<?php print $Gender_error;?>">Gender</td>
            <td><input name="Gender" type="text" id="Gender" tabindex=5 style="color: <?php print $TextColour;?>;" value="<?php print $_SESSION['Gender'] ;?>" size="30" readonly/></td>
        </tr>
        <tr>
            <td class="<?php print $FirstName_error;?>">First Name</td>
            <td><input name="FirstName" type="text" id="FirstName" tabindex=3 style="color: <?php print $TextColour;?>;" value="<?php print $_SESSION['FirstName'] ;?>" size="30" readonly/></td>

            <td class="<?php print $Surname_error;?>">Surname</td>
            <td><input name="Surname" type="text" id="Surname" tabindex=4 style="color: <?php print $TextColour;?>;" value="<?php print $_SESSION['Surname'] ;?>" size="30" readonly /></td>

PDF Creation

//DETAILS OF MAIN MEMBER
$pdf->filledRectangle(50,740,500,15);

//Set Color to White 
$pdf->setColor(255,255,255);

$pdf->addText(230,744,10,"DETAILS OF MAIN MEMBER");

//Set Color back to black 
$pdf->setColor(0,0,0);

$pdf->Rectangle(50,720,100,15);
$pdf->addText(93,724,8,"Title");
$pdf->addText(160,724,8,"{$_SESSION['Title']}");

$pdf->Rectangle(300,720,100,15);
$pdf->addText(335,724,8,"Gender");
$pdf->addText(410,724,8,"{$_SESSION['Gender']}");

$pdf->Rectangle(50,700,100,15);
$pdf->addText(80,704,8,"First Name");
$pdf->addText(160,704,8,"{$_SESSION['FirstName']}");

$pdf->Rectangle(300,700,100,15);
$pdf->addText(334,704,8,"Surname");
$pdf->addText(410,704,8,"{$_SESSION['Surname']}");

So As you can see in the pdf create snippet above, If I had …

fabzster 0 Light Poster

can anyone else offer some assistance?

fabzster 0 Light Poster

many thanks fro the reply.

I already call another function "enabledisableinput" which enables or disables the inputs based on clicking the tickbox.

function enabledisableinput(Checkbox,Name,Surname,IDNumber,DOB,Passport)
    {
        if(document.getElementById(Checkbox).checked)
                    {   
                        //enables the inputs when tickbox is checked
                        document.getElementById(Name).disabled = false;
                        document.getElementById(Surname).disabled = false;
                        document.getElementById(IDNumber).disabled = false;
                        document.getElementById(DOB).disabled = false;
                        document.getElementById(Passport).disabled = false;
                    }
                else
                    {
                       //Disables the inputs if checkbox is unticked
                        document.getElementById(Name).disabled = true;
                        document.getElementById(Surname).disabled = true;
                        document.getElementById(IDNumber).disabled = true;
                        document.getElementById(DOB).disabled = true;
                        document.getElementById(Passport).disabled = true;


                        //This clears the inputs for the relevant dependant when the checkbox is unticked 
                        document.getElementById(Name).value = '';
                        document.getElementById(Surname).value = '';
                        document.getElementById(IDNumber).value = '';
                        document.getElementById(DOB).value = '';
                        document.getElementById(Passport).value = '';

                    }

        }

So Basically I need to enable/disable the inputs by ticking the check box and also if the page loads it needs to check that if the box is ticked and either enable or disable the input

see html below

<tr>
            <tr><td class="DepTitle"><input type="checkbox" tabindex=18  onclick="enabledisableinput('Dep1','Dep1Name','Dep1Surname','Dep1IDNumber','Dep1DOB','Dep1Passport')" id="Dep1" name="Dep1" value="1" <?php if($_SESSION['Dep1'] == 1) print "checked='checked'"?> >Dependant 1</td></tr>    
            <td class="<?php print $Dep1Name_error;?>">Dependant 1 Name</td>
            <td><input name="Dep1Name" type="text" id="Dep1Name" tabindex=19 style="color: <?php print $TextColour;?>;" value="<?php print $_SESSION['Dep1Name'] ;?>" size="30" disabled/></td>

            <td class="<?php print $Dep1Surname_error;?>">Dependant 1 Surname</td>
            <td><input name="Dep1Surname" type="text" id="Dep1Surname" tabindex=20 style="color: <?php print $TextColour;?>;" value="<?php print $_SESSION['Dep1Surname'] ;?>" size="30" disabled /></td>

        </tr>

        <tr>
            <td class="<?php print $Dep1IDNumber_error;?>">Identity Number</td>
            <td><input name="Dep1IDNumber" type="text" id="Dep1IDNumber" tabindex=21 style="color: <?php print $TextColour;?>;" value="<?php print $_SESSION['Dep1IDNumber'] ;?>" size="30" disabled/></td>

            <td class="<?php print $Dep1DOB_error;?>">Date Of Birth</td>
            <td><input name="Dep1DOB" type="text" id="Dep1DOB" tabindex=22 style="color: <?php print $TextColour;?>;" value="<?php print $_SESSION['Dep1DOB'] ;?>" size="30" readonly disabled …
fabzster 0 Light Poster

Hi

I am having issues with a function that I created, I execute the below function on load on another page.
I would like it to enable all the inputs if a check box is selected or disable all inputes if it is not.

This works but it only works wih the first checkbox, so it's as if the code does not hit the next If Statement, If I move the Dep2 If statement above one then 2 it works an all others dont

//This function is used on the loading of the page so that if any of the dependant check boxes are ticked that the forms stay enabled
function autoenabledisableinput()
    {
             document.getElementById("DepID").style.display= 'none'; //hide div element on load


            if(document.getElementById('Dep1').checked)
                    { 
                        document.getElementById("DepID").style.display = ''; //show element when clicked

                        document.getElementById('Dep1Name').disabled = false;
                        document.getElementById('Dep1Surname').disabled = false;
                        document.getElementById('Dep1IDNumber').disabled = false;
                        document.getElementById('Dep1DOB').disabled = false;
                        document.getElementById('Dep1Passport').disabled = false;  
                    }

            if(document.getElementById('Dep2').checked)
                    {
                        document.getElementById("DepID").style.display = ''; //show element when clicked

                        document.getElementById('Dep2Name').disabled = false;
                        document.getElementById('Dep2Surname').disabled = false;
                        document.getElementById('Dep2IDNumber').disabled = false;
                        document.getElementById('Dep2DOB').disabled = false;
                        document.getElementById('Dep2Passport').disabled = false;  
                    }
            if(document.getElementById('Dep3').checked)
                    {
                        document.getElementById("DepID").style.display = ''; //show element when clicked

                        document.getElementById('Dep3Name').disabled = false;
                        document.getElementById('Dep3Surname').disabled = false;
                        document.getElementById('Dep3IDNumber').disabled = false;
                        document.getElementById('Dep3DOB').disabled = false;
                        document.getElementById('Dep3Passport').disabled = false;  
                    }
            if(document.getElementById('Dep4').checked)
                    {
                        document.getElementById("DepID").style.display = ''; //show element when clicked

                        document.getElementById('Dep4Name').disabled = false;
                        document.getElementById('Dep4Surname').disabled = false;
                        document.getElementById('Dep4IDNumber').disabled = false;
                        document.getElementById('Dep4DOB').disabled = false;
                        document.getElementById('Dep4Passport').disabled = false;  
                    }
            if(document.getElementById('Dep5').checked)
                    {
                        document.getElementById("DepID").style.display = ''; //show element when clicked

                        document.getElementById('Dep5Name').disabled = false;
                        document.getElementById('Dep5Surname').disabled = false;
                        document.getElementById('Dep5IDNumber').disabled = false;
                        document.getElementById('Dep5DOB').disabled = false;
                        document.getElementById('Dep5Passport').disabled = false;  
                    }
            if(document.getElementById('Dep6').checked)
                    {
                        document.getElementById("DepID").style.display …
fabzster 0 Light Poster

yes thank you sooooo much, I managed to figure that out, how would I then keep that in a session on the page with the select as currently if you refresh the page the dropdowns refresh.

this definitely works but with a little flaw ...

let me explain...

if a user enters data on the form and lets say forgets to fill in a field and clicks submit it will validate and bounce back and all the data entered by the user is still available on the form so the user just fills out what they missed instead of retyping everything.

I normally keep that info in sessions, but beacuse of the way the chained select works currently it just resets.

I would normally have sonmething like this:

<label for="PhoneMake">Phone Make</label>     
               <select name="PhoneMake" id="PhoneMake">
               <option><?php print $_SESSION['PhoneMake']?></option>
               </select> 
fabzster 0 Light Poster

I think I know what the error is.

The Variable selectedvalue is not being passed to my php function. how do I fix that?

fabzster 0 Light Poster

Many thanks for all your effort, I have changed this for my use but cannot get it to work, please see below:

My Html section:

        <div>

            <label for="PhoneMake">Phone Make</label>     
               <select name="PhoneMake" id="PhoneMake">

              </select> 
        </div>

        <div>
            <label for="PhoneModel">Phone Model</label>    
                <select name="PhoneModel" id="PhoneModel">

            </select>
        </div>

My Php section (getModels.php):

<?php
//**************************************
//     Page load dropdown results     //
//**************************************
function getMake()
{
        include_once('./includes/dbinfo.inc');
    $result = mysql_query("SELECT DISTINCT Make FROM tblphones") 
    or die(mysql_error());

      while($x = mysql_fetch_array( $result )) 

        {
           echo '<option value="'.$x['Make'].'">'.$x['Make'].'</option>';
        }

}

//**************************************
//     First selection results     //
//**************************************

if($_GET['func'] == "getMake" && isset($_GET['func'])) { 
   getMake($_GET['selectedValue']); 
}

function getModel($selectedValue)
{  
        include_once('./includes/dbinfo.inc');
    $result = mysql_query("SELECT * FROM tblphones WHERE Make='$selectedValue'") 
    or die(mysql_error());

      while($x = mysql_fetch_array( $result )) 

        {
           echo '<option value="'.$x['Model'].'">'.$x['Model'].'</option>';
        }

}

The Script between my <head> tags:

<script type="text/javascript">

var PhoneMake = 'PhoneMake'; // First select, when this changes the select two will be reloaded
var PhoneModel = 'PhoneModel'; // Second select, reloaded when the first changes
$(function() { // On DOM Loaded
    $.get("getModels.php", { // Request the options for the first select
        func: "getMake",
        drop_var: ""
    }, function(options) { 
        $("#" + PhoneMake) // Get the object for the first select
            .html(options) // Set the options returned
            .unbind('change') // Clean any change listener
            .change(function() { // Add a change event listener
                // When the change occurs the second select will be loaded
                var selectedValue = $(this).val(); // Gets the selected value from the first select
                $.get("getModels.php", { // Request the options for the second select …
fabzster 0 Light Poster

Many thanks for all your effort, I have changed this for my use but cannot get it to work, please see below:

My Html section:

        <div>

            <label for="PhoneMake">Phone Make</label>     
               <select name="PhoneMake" id="PhoneMake">

              </select> 
        </div>

        <div>
            <label for="PhoneModel">Phone Model</label>    
                <select name="PhoneModel" id="PhoneModel">

            </select>
        </div>

My Php section (getModels.php):

<?php
//**************************************
//     Page load dropdown results     //
//**************************************
function getMake()
{
        include_once('./includes/dbinfo.inc');
    $result = mysql_query("SELECT DISTINCT Make FROM tblphones") 
    or die(mysql_error());

      while($x = mysql_fetch_array( $result )) 

        {
           echo '<option value="'.$x['Make'].'">'.$x['Make'].'</option>';
        }

}

//**************************************
//     First selection results     //
//**************************************

if($_GET['func'] == "getModel" && isset($_GET['func'])) { 
   getModel($_GET['drop_var']); 
}

function getModel($selectedValue)
{  
        include_once('./includes/dbinfo.inc');
    $result = mysql_query("SELECT * FROM tblphones WHERE Make='$selectedValue'") 
    or die(mysql_error());

      while($x = mysql_fetch_array( $result )) 

        {
           echo '<option value="'.$x['Model'].'">'.$x['Model'].'</option>';
        }

}

The Script between my <head> tags:

<script type="text/javascript">

var PhoneMake = 'PhoneMake'; // First select, when this changes the select two will be reloaded
var PhoneModel = 'PhoneModel'; // Second select, reloaded when the first changes
$(function() { // On DOM Loaded
    $.get("getModels.php", { // Request the options for the first select
        func: "getMake",
        drop_var: ""
    }, function(options) { 
        $("#" + PhoneMake) // Get the object for the first select
            .html(options) // Set the options returned
            .unbind('change') // Clean any change listener
            .change(function() { // Add a change event listener
                // When the change occurs the second select will be loaded
                var selectedValue = $(this).val(); // Gets the selected value from the first select
                $.get("getModels.php", { // Request the options for the second select …
fabzster 0 Light Poster

Hi

Many thanks for the time taken to reply, it is much appreciated.

This was taken from the tutorial link posted above and my Java script skills are somewhat non-existant. Hence why I did not comment anything above as I did not exactly know what it did. By looking at it I kinda understood what each section did, but am unable to change this (make it simpler) in order for it to do what I need.

This actually creates the <Select></select> box and has a little transistion before it does that.

I would really just like it to populate a <select> box that I already have on that page.

Could you perhaps assist with that?

The php file that is gets info from has 2 functions, the first one for retrieving the initial values:

function getTierOne()
{
    $result = mysql_query("SELECT DISTINCT tier_one FROM two_drops") 
    or die(mysql_error());

      while($tier = mysql_fetch_array( $result )) 

        {
           echo '<option value="'.$tier['tier_one'].'">'.$tier['tier_one'].'</option>';
        }

}

The second function to create the <Select>:

if($_GET['func'] == "drop_1" && isset($_GET['func'])) { 
   drop_1($_GET['drop_var']); 
}

function drop_1($drop_var)
{  
    include_once('db.php');
    $result = mysql_query("SELECT * FROM two_drops WHERE tier_one='$drop_var'") 
    or die(mysql_error());

    echo '<select name="tier_two" id="tier_two">
          <option value=" " disabled="disabled" selected="selected">Choose one</option>';

           while($drop_2 = mysql_fetch_array( $result )) 
            {
              echo '<option value="'.$drop_2['tier_two'].'">'.$drop_2['tier_two'].'</option>';
            }

    echo '</select> ';
    echo '<input type="submit" name="submit" value="Submit" />';
}

I would Like to have the second Select more like the first, like this:

function drop_1($drop_var)
{
    $result = mysql_query("SELECT * FROM two_drops WHERE tier_one='$drop_var'") 
    or die(mysql_error());

      while($drop_2 = …
fabzster 0 Light Poster

Hi

I managed to get the tutorial from the below link to work.
http://www.blueicestudios.com/chained-select-boxes-using-php-mysql-ajax/comment-page-11/#comment-34199

I would love to know how to edit this script so as to get the first dropdown to populate an already existing dropdown without the loader image and without the hiding of any dropdowns.

I would assume you only have to make changes to this section:

$(document).ready(function() {
    $('#wait_1').hide();
    $('#drop_1').change(function(){
      $('#wait_1').show();
      $('#result_1').hide();
      $.get("func.php", {
        func: "drop_1",
        drop_var: $('#drop_1').val()
      }, function(response){
        $('#result_1').fadeOut();
        setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400);
      });
        return false;
    });
});

function finishAjax(id, response) {
  $('#wait_1').hide();
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
}

Your assistance is greatly appreciated

fabzster 0 Light Poster

Hi

I use the following Query:

SELECT DISTINCT COUNT(tblpolicies.PolicyNumber)AS Figures, tblstores.GroupName, tblstores.StoreName, tblstores.StoreType FROM tblpolicies, tblstores
                     WHERE DateReceived BETWEEN '2012-06-01' AND '2012-06-30' AND tblstores.StoreType='FLAGSHIP' AND tblpolicies.PolicyStatus='ACTIVE' AND tblstores.StoreStatus='ACTIVE' AND tblpolicies.StoreId=tblstores.StoreId
GROUP BY StoreName ORDER BY Figures DESC

What this does is give me a result:

95 GroupName StoreName StoreType

This will only show me stores that have sold policies between the specified dates.

How would I go about showing all stores even if they did not have any policies sold in the specific periods and have them display a 0 for figures.

fabzster 0 Light Poster

Hi

thanks for the replies

I managed to get my script to work, but the question is can I do this whilst the DB is live every 2 Hrs?

fabzster 0 Light Poster

Hi

I have 2 MYSQL servers One on a LAN and one on a dedicated server at an ISP.
I cannot run normal replication as my ISP does not allow this.

I have however written a script that will dump the data to a .sql file and ftp it to the server on the Web and import it.

Is this ok to run the way it is? I mean is it ok to import data in this fashion every 2hours on a live DB?

fabzster 0 Light Poster

Hi

I have a MYSQL DB hosted on a Win 2003 server on my LAN
and a Mysql DB on a dedicated (linux) server at our ISP.

I would like to dump a few tables to a .sql file and ftp it to the server and then import the .sql file automatically via a cron job.

I can do the FTP etc. But I am unable to get the exporting and importing to work, not sure why.

I would really appreciate some assistance

fabzster 0 Light Poster

Hi

I pull data from a MYSQL database to populate a Drop down

            <td class="<?php print $Bank_ca_error;?>">Bank Name</td>
            <td>
                <select name="Bank" id="Bank" tabindex=24 style="color: <?php print $TextColour;?>"/>
                <option><?php print $_SESSION['Bank_ca'] ;?></option>
                <?php
                //Get Data to populate drop down
                $BankQuery = "SELECT BankName FROM tblbank ORDER BY BankName";

                $BankResult = mysql_query ($BankQuery);

                While($nt=mysql_fetch_array($BankResult))
                        {
                        print"<option $nt[BankName]>$nt[BankName]</option>";
                        }

                ?>
                </select>
            </td> 

I would like based on the value selected populate a text input. So Basically Select the Bank from the List and have it autopopulate the Universal Branch Code in the text input.

I saw an example using Jquery, But I am a complete noob when it comes to this and I cannot get it to work properly

I added the following in the Head section

<script type="text/javascript" src="jquery-1.4.2.min.js"></script>

<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('#Bank').live('change', function(event) {
            $.ajax({
                url     : 'getData.php',
                type    : 'POST',
                dataType: 'json',
                data    : $('#myform').serialize(),
                success: function( data ) {
                       for(var id in data) {        
                              $(id).val( data[id] );
                       }
                }
            });
        });
    });
</script>

I then Added this into the getData.php file

<?php

include "../../../includes/dbinfo.inc";

//Connect to database
mysql_connect($db_host, $db_username, $db_password);
@mysql_select_db($db_database) or die("Unable to select database");

$BankName = $_POST['Bank']; // Selected Bank

$query  = "SELECT * FROM tblbank WHERE BankName ='{$BankName}'";
$result = mysql_query($query);
$row = mysql_fetch_array($result)

$BranchCode = $row['UniversalCode'];


$arr = array( 'input#BranchCode' => $BranchCode );
echo json_encode( $arr );

?>

and added the Following to around the inputs and dropdown concerned

<form id='myform'>

</form>

I would really appreciate …

fabzster 0 Light Poster

Many Thanks for the assistance guy's

I used the code I posted earlier, For Some reason when I run that in Chrome it times out eventually .... Very Weird!

When I run the code in IE, it runs perfectly, I cannot understand why though

fabzster 0 Light Poster

I modified what you gave me in order to suite my needs, unfortunately this does not run sometimes

$Q = "SELECT COUNT(tblpolicies.PolicyNumber)AS Figures, tblpolicies.ConsultantFullName, tblstores.StoreType  FROM tblpolicies, tblstores
      WHERE tblPolicies.DateReceived BETWEEN '{$StartDate}' AND '{$EndDate}' AND tblpolicies.PolicyStatus='Active' AND
      ConsultantFullName!='HOUSE CONSULTANT' AND ConsultantFullName!='PINNACLE FINRITE' AND tblpolicies.StoreId=tblstores.StoreId
      GROUP BY tblpolicies.ConsultantFullName ORDER BY Figures DESC";

$R = mysql_query($Q);
$entries = array();
while($row = mysql_fetch_assoc($R)){
	
	
	If(($row['StoreType']) == "FLAGSHIP" || "SUPER LARGE")
				{
					$row['Figures'] = floor($row['Figures'] / 15); 
			
				}
				
	If(($row['StoreType']) == "LARGE" || "SUPER MEDIUM")
				{
					$row['Figures'] = floor($row['Figures'] / 10); 
			
				}
				
	If(($row['StoreType']) == "MEDIUM")
				{
					$row['Figures'] = floor($row['Figures'] / 8); 
			
				}
	If(($row['StoreType']) == "SMALL" || "KIOSK")
				{
					$row['Figures'] = floor($row['Figures'] / 5); 
			
				}
	
	
	
	if($row['Figures'] > 0){
		$i = 0;
		while($i < $row['Figures']){
			$entries[] = $row['ConsultantFullName'];
			$i++;
		}
	}
	
}

echo "Total Entries: ".count($entries)."<br/>\r\n";
$entryBreakdown = array();
foreach($entries as $v){
	if(!ISSET($entryBreakdown[$v])){
		$entryBreakdown[$v] = 1;
	}else{
		$entryBreakdown[$v]++;
	}
}
echo "Breakdown by consultant:<br/>\r\n";
foreach($entryBreakdown as $k=>$v){
	echo "{$k} Has {$v} Entries<br/>\r\n";
}
 
echo "Random winners:<br/>\r\n";
$winners = array();
$numwinners = 3;
$i = 0;
while($i < $numwinners){
	$rand_key = array_rand($entries);
	if(!in_array($entries[$rand_key],$winners)){
		$winners[] = $entries[$rand_key];
		$i++;
	}
}
echo $winners[0] . "<br/>\r\n";
echo $winners[1] . "<br/>\r\n";
echo $winners[2] . "<br/>\r\n";
echo "Congrats!";
fabzster 0 Light Poster

my second post was a solution to keep picking till it has 3 different winners :)

Hi Thanks seems I am pretty close to a 100% solution with your help

I did however not ask the question correctly (My Appologies), Some consultants belong to stores that get an entry every 10 sales and some belong to stores that get entries every 15 sales, so we cannot do this in the query but in the PHP code itself.

Any ideas?

fabzster 0 Light Poster

for 1 winner:

$num_sales_per_entry = 10;
while($data = mysql_fetch_array($result)){
  $tries = floor($data['sales']/$num_sales_per_entry);
  for($x=0;$x<$tries;$x++){
    $entries[] = $data['consultant'];
  } 
}
shuffle($entries);
echo "WINNER = {$entries[$x]}";

Thanks for the prompt reply

How does this give more chance to consultants that have more entries though?

fabzster 0 Light Poster
SELECT consultant,FLOOR(SUM(`numsales`)/10) AS `entries` FROM `salestable` GROUP BY consultant
<?php 
$Q = 'SELECT consultant,FLOOR(SUM(`numsales`)/10) AS `entries` FROM `salestable` GROUP BY consultant';
$R = mysql_query($Q);
$entries = array();
while($row = mysql_fetch_assoc($R)){
	if($row['entries'] > 0){
		$i = 0;
		while($i < $row['entries']){
			$entries[] = $row['consultant'];
			$i++;
		}
	}
}
echo "Total Entries: ".count($entries)."<br/>\r\n";
$entryBreakdown = array();
foreach($entries as $v){
	if(!ISSET($entryBreakdown[$v])){
		$entryBreakdown[$v] = 1;
	}else{
		$entryBreakdown[$v]++;
	}
}
echo "Breakdown by consultant:<br/>\r\n";
foreach($entryBreakdown as $k=>$v){
	echo "{$k} Has {$v} Entries<br/>\r\n";
}

echo "Random winners:<br/>\r\n";
$rand_keys = array_rand($entries, 3);
echo $entries[$rand_keys[0]] . "<br/>\r\n";
echo $entries[$rand_keys[1]] . "<br/>\r\n";
echo $entries[$rand_keys[2]] . "<br/>\r\n";
echo "Congrats!";
?>

Hi

Many thanks for the reply

I need only 1 winner each month, I just need to know the following

lets assume i get the below results.....

Consultant1 2
Consultant2 3
Consultant3 8
Consultant4 0
etc......


I know based on the amount of sales.... Consultant 2 should have 2 entries into the draw Consultant 3 8 entries. so their chances of coming up randomly should increase with the amount of entries they have, they should be weighted more somehow.

fabzster 0 Light Poster

Hi

We have a competition running that I would like to automate getting the results with PHP from my MYSQL DB.

I can run a query on the Database to get the following results

Consultant1 20 sales
Consultant2 10 sales
Consultant3 5 sales
Consultant4 1 sales
Consultant5 3 sales
Consultant6 8 sales
Consultant7 30 sales
Consultant8 17 sales

Now this is where it gets tricky for me........

For every 10 sales the consultant gets thier name entered in a draw, so if the have 30 they have 3 entries.

perhaps I need to add all the entries to a virtual table or array of sorts then randomly pick one as the winner.

Anyone have any ideas on how I should be going about this??

I value your assistance

fabzster 0 Light Poster

this is the script I created but PHP eventually times out

<?php

//Include PHP Mailer Class
require("class.phpmailer.php");

$LogDateTime = date("Y-m-d H:i:s");
$date = date("Y-m-d");

$date = date("Y-m-d");

$ftp_server = "FTP_Address";
$ftp_user_name = "FTP_UserName";
$ftp_user_pass = "FTP_Password";

$local_file = './downloaded/CellUpload'.$date.'.xls';
$server_file = 'CellUpload'.$date.'.xls';

// set up basic connection
$conn_id = ftp_connect($ftp_server); 

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 

// check connection
if ((!$conn_id) || (!$login_result))
    { 
        $LogDateTime = date("Y-m-d H:i:s");
        //write data to logfile
        $handle = fopen("./logs/log.txt", "a");
        fwrite($handle,""."$LogDateTime"." "."[FTP CONNECT ERROR]"." "."Failed To Connect To"." "."$ftp_server"."\r\n");
        fclose($handle);
        
        $LogDateTime = date("Y-m-d H:i:s");
        //write data to logfile
        $handle = fopen("./logs/log.txt", "a");
        fwrite($handle,""."$LogDateTime"." "."[FTP SLEEP]"." "."Waiting 60 Seconds To Retry Connection To"." "."$ftp_server"."\r\n");
        fclose($handle);
 
        sleep(60);
        header("Location:ftp_script2.php");
           
        exit; 
    }
    else
        {
            $LogDateTime = date("Y-m-d H:i:s");
            
            //write data to logfile
            $handle = fopen("./logs/log.txt", "a");
            fwrite($handle,"\r\n"."$LogDateTime"." "."[FTP CONNECTED]"." "."Connect Successfully To"." "."$ftp_server"."\r\n");
            fclose($handle);
        }

// Change The Directory
if (ftp_chdir($conn_id, "/public_html/reports/exports"))
    {
        $LogDateTime = date("Y-m-d H:i:s");
        //write data to logfile
        $handle = fopen("./logs/log.txt", "a");
        fwrite($handle,""."$LogDateTime"." "."[FTP CHANGED DIRECTORY]"." "."Current Directory Is Now:"."(./public_html/reports/exports)"."\r\n");
        fclose($handle);
    }
else
    { 
        $LogDateTime = date("Y-m-d H:i:s");
        //write data to logfile
        $handle = fopen("./logs/log.txt", "a");
        fwrite($handle,"\r\n"."$LogDateTime"." "."[FTP CHANGED DIRECTORY ERROR]"."Failed To Change Directory To:"."(./public_html/reports/exports)"."\r\n");
        fclose($handle);
        exit;
    }

// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY))
    {
        $LogDateTime = date("Y-m-d H:i:s");
        //write data to logfile
        $handle = fopen("./logs/log.txt", "a");
        fwrite($handle,""."$LogDateTime"." "."[FTP DOWNLOAD]"." "."File Successfully Downloaded To:"." "."($local_file)"."\r\n");
        fclose($handle);
    }
else
    {
        $LogDateTime = date("Y-m-d H:i:s");
        //write data to logfile
        $handle = fopen("./logs/log.txt", "a");
        fwrite($handle,"".$LogDateTime." …
fabzster 0 Light Poster

Hi

I have a script that is scheduled to run with task scheduler will download a file via FTP and import it to a mysql DB
How would I go about handling the retries if there is either a problem with the connection or something.

I tried going about it using the sleep(); function and using header("Location:file2.php")
then redirecting it back to the original thus causing a loop.

The reason I went about it this way is that if I just used a loop in the original page then it detected that eventually timed out.

What is the best way to go about it?

fabzster 0 Light Poster

Thank You

I managed to find a solution though

SELECT tblpolicies.PolicyNumber
     , tblpolicies.StoreId
     , tblpolicies.ConsultantFullName
     , tblpolicies.DateReceived
     , tblpolicies.ClientFullName
     , tblpolicies.Comment
     , tblpolicies.Query
     , tblpolicies.PolicyStatus
     , tblpolicies.DateModified
     , Groups.GroupName
     , Groups.StoreName
     , Groups.StoreTarget
     , Groups.StoreManager
     , Groups.PortfolioName
     , Groups.StoreStatus
     , Groups.RepName
     , Policies.total_policies
  FROM tblstores AS Groups
INNER
  JOIN tblpolicies
    ON tblpolicies.StoreId = Groups.StoreId
   AND tblpolicies.PolicyStatus='ACTIVE'
   AND tblpolicies.DateReceived BETWEEN '{$_SESSION['StartDateRepReport']}'
                                    AND '{$_SESSION['EndDateRepReport']}'
INNER
  JOIN ( SELECT StoreId
              , COUNT(*) AS total_policies
           FROM tblpolicies
          WHERE DateReceived BETWEEN '{$_SESSION['StartDateRepReport']}'
                                 AND '{$_SESSION['EndDateRepReport']}'
                                 AND tblpolicies.PolicyStatus = 'ACTIVE'
         GROUP
             BY StoreId ) AS Policies
    ON Policies.StoreId = Groups.StoreId
 WHERE Groups.RepName='{$_SESSION['RepNameReport']}'
   AND Groups.StoreStatus='ACTIVE'
ORDER 
    BY Groups.StoreId
     , tblpolicies.DateReceived

Hope this helps someone else

fabzster 0 Light Poster

Hi

I have a join query which I use for a report
ok

I have a query to give me results for a report that will give me all the stores that sold policies from a group during a period. It works however I cannot get it to give me the totals per store.

store name
store details (managers etc)
then below that I print in PHP the actual policies in a list (attached pdf) now I would like the
totals for the specific store to be displayed in the header of the store(as long as I get the result from the Mysql query I can place it there with php)

SELECT tblpolicies.PolicyNumber
     , tblpolicies.StoreId
     , tblpolicies.ConsultantFullName
     , tblpolicies.DateReceived
     , tblpolicies.ClientFullName
     , tblpolicies.Comment
     , tblpolicies.Query
     , tblpolicies.PolicyStatus
     , tblpolicies.DateModified
     , Groups.GroupName
     , Groups.StoreName
     , Groups.StoreTarget
     , Groups.StoreManager
     , Groups.PortfolioName
     , Groups.StoreStatus
     , Groups.RepName
     , Groups.ProvinceName
  FROM tblpolicies
LEFT OUTER
  JOIN ( SELECT StoreId,
                StoreName, StoreManager, GroupName, StoreTarget, PortfolioName
                , StoreStatus, RepName, ProvinceName 
           FROM tblstores
         GROUP
             BY StoreId ) AS Groups
    ON tblpolicies.StoreId = Groups.StoreId
WHERE DateReceived BETWEEN '2011-01-01' AND '2011-01-31'
 AND StoreStatus='ACTIVE' ORDER BY GroupName

I also attached some data in pdf(didnt allow me to upload excel files)from the tblstores and tblpolicies tables so that you may see the structure of the data.

Hope this helps

fabzster 0 Light Poster

Hi

I am using the following join query to get a list of stores that have sold policies during the day.

But I need it to be distinct

$Query = mysql_query("SELECT  tblpolicies.StoreId
                     , tblpolicies.DateReceived
                     , DailyGroup.GroupName
                     , DailyGroup.StoreName
                     , DailyGroup.PortfolioName
                     FROM tblpolicies
                     LEFT OUTER
                     JOIN (SELECT StoreId
                                , GroupName, StoreName, PortfolioName
                           FROM tblstores GROUP BY StoreId) AS DailyGroup
                           ON tblpolicies.storeId = DailyGroup.StoreId
                     WHERE DateReceived ='2010-07-01' ORDER BY GroupName

When I try using DISTINCT it doesnt work properly

$Query = mysql_query("SELECT DISTINCT tblpolicies.StoreId
                     , tblpolicies.DateReceived
                     , DailyGroup.GroupName
                     , DailyGroup.StoreName
                     , DailyGroup.PortfolioName
                     FROM tblpolicies
                     LEFT OUTER
                     JOIN (SELECT StoreId
                                , GroupName, StoreName, PortfolioName
                           FROM tblstores GROUP BY StoreId) AS DailyGroup
                           ON tblpolicies.storeId = DailyGroup.StoreId
                     WHERE DateReceived ='2010-07-01' ORDER BY GroupName")
fabzster 0 Light Poster

Thank you!

fabzster 0 Light Poster

Ok I see now, but how do I then return both the Session and the answer?

fabzster 0 Light Poster

Hi

I am trying to get this function to work but having issues

// check that policy number not entered on the DB if no policy is entered skip Mysql query	
	function validatePolicyNumber($PolicyNumber){
		//Return Session Value so user does not have to retype entry 
		return $_SESSION['PolicyNumberAdd'] = $PolicyNumber;
		
		$Connection = mysql_connect("localhost", "root", "")or die(mysql_error());
		mysql_select_db('mobility', $Connection) or die('Could not select database.');

		//if it's NOT valid
		$UniqueQuery = "SELECT $PolicyNumber FROM tblpolicies WHERE PolicyNumber='{$PolicyNumber}'";
		
		$result = mysql_query($UniqueQuery, $Connection);	
	   

		if(mysql_num_rows($result) >=1 )	
			return false;
		//if it's valid
		else
			return true;
		
        }

I tried to even use a global variable but still didnt work

// check that policy number not entered on the DB if no policy is entered skip Mysql query	
	function validatePolicyNumber($PolicyNumber){
		//Return Session Value so user does not have to retype entry 
		return $_SESSION['PolicyNumberAdd'] = $PolicyNumber;
		
                global $Connection;

		$Connection = mysql_connect("localhost", "root", "")or die(mysql_error());
		mysql_select_db('mobility', $Connection) or die('Could not select database.');

		//if it's NOT valid
		$UniqueQuery = "SELECT $PolicyNumber FROM tblpolicies WHERE PolicyNumber='{$PolicyNumber}'";
		
		$result = mysql_query($UniqueQuery, $Connection);	
	   

		if(mysql_num_rows($result) >=1 )	
			return false;
		//if it's valid
		else
			return true;
		
        }

Please assist

fabzster 0 Light Poster

Much better Thanks :)

It definately seperates the stores no, but I only want it to create a space between stores not go to a new page for every store. Also on the first page using ur code it prints at the bottom then skips to the next page.

I have attached the output

fabzster 0 Light Poster

Hi

It skips 1 line as intended. My problem is that it doesnt seperate when the new store is in the list for some reason, I also tried using your method and it changes the page but again not when the store changes. I have attached both pdf's for you to see the results.

my code gives me this output:

68351 11CCC 24hrLelanieJooste M VAN JAARSVELD 2006-04-03 00:00:00

80253 11GEE 24HrZandile EN SIBISI 2006-04-01 00:00:00

80251 11GEE 24HrZandile KD MAKGATHO 2006-04-01 00:00:00
79681 11HGC 24hrLorna SE MABASO 2006-04-01 00:00:00 No CPD Attached

79682 11HGC 24HrGanief1 R MARCUS 2006-04-01 00:00:00
70744 11HGC 24HrAdeeba SETHOGA 2006-04-02 00:00:00
79683 11HGC 24HrAdeeba MS SITHOLE 2006-04-02 00:00:00
69931 12CEL 24HrThembi RR Makhafola 2006-04-01 00:00:00

I would like it to do this:

68351 11CCC 24hrLelanieJooste M VAN JAARSVELD 2006-04-03 00:00:00

80253 11GEE 24HrZandile EN SIBISI 2006-04-01 00:00:00
80251 11GEE 24HrZandile KD MAKGATHO 2006-04-01 00:00:00

79681 11HGC 24hrLorna SE MABASO 2006-04-01 00:00:00 No CPD Attached
79682 11HGC 24HrGanief1 R MARCUS 2006-04-01 00:00:00
70744 11HGC 24HrAdeeba SETHOGA 2006-04-02 00:00:00
79683 11HGC 24HrAdeeba MS SITHOLE 2006-04-02 00:00:00

69931 12CEL 24HrThembi RR Makhafola 2006-04-01 00:00:00

fabzster 0 Light Poster

You need to save the store id (near the end of your While loop) then and compare each new one to the previous one at the start of the loop. When you get a new one, then use the ezNewPage()command to start a new page (and reset your line counter).

Many Thanks for the reply

I tried the following to test and give me a space between storeId's

While($x=mysql_fetch_array($queryP)){ 

$pdf->addText(50,$p,7,"{$x['PolicyNumber']}");
$pdf->addText(80,$p,7,"{$x['StoreId']}");
$pdf->addText(120,$p,7,"{$x['NickName']}");
$pdf->addText(220,$p,7,"{$x['ClientsName']}");
$pdf->addText(330,$p,7,"{$x['DateReceived']}");
$pdf->addText(410,$p,7,"{$x['Comments']}");
$p = $p - 10;

if($p == 10){
    $pdf->ezNewPage();
    $p = 750;
    }


if($x['StoreId'] != $StoreId){
$p = $p - 10;    
}

$StoreId = $x['StoreId'];
}

But it doesnt work properly and I cant figure out why

fabzster 0 Light Poster

Hi

I have a db that has the following Data for example:

PolicyNumber, StoreId, ConsultantName,ClientName, ClientSurname

I would like to have a report that will give me a list of policies done for that day seperated by store printed to PDF.

So Basically

Store - 12CEL
24Hr001 Bob Joe Soap
24Hr002 Bill Gill Henry

Store - 1156
24Hr003 Luke Manfred Kiy
24Hr004 Peter Ursula Jent

I currently use R&OS for pdf Printing
http://www.ros.co.nz/pdf

The Code below Gives me all policies, I just need to now seperate them in the PDF

//include pdf class
include ('class.ezpdf.php');

//Include PHP Mailer Class
require("class.phpmailer.php");

//Connect to database
mysql_connect("localhost", "root", "");
@mysql_select_db("mobility") or die("Unable to select database");

$queryP= mysql_query("SELECT * FROM tblpolicies WHERE CaptureDate='2006-04-03' ORDER BY StoreId");

$pdf =& new Cezpdf();
//$pdf->addJpegFromFile('policy.jpg',60,$pdf->y-750,500,0);
$pdf->selectFont('./fonts/Helvetica.afm');

$p = 750;


While($x=mysql_fetch_array($queryP)){ 

$pdf->addText(50,$p,7,"{$x['PolicyNumber']}");
$pdf->addText(80,$p,7,"{$x['StoreId']}");
$pdf->addText(120,$p,7,"{$x['NickName']}");
$pdf->addText(220,$p,7,"{$x['ClientsName']}");
$pdf->addText(330,$p,7,"{$x['DateReceived']}");
$pdf->addText(410,$p,7,"{$x['Comments']}");
$p = $p - 10;

if($p == 10){
    $pdf->ezNewPage();
    $p = 750;
    }



}

$pdf->ezText("\n\n\n\n\n\n\n" . $body,16,array('justification'=>'centre'));
$pdf->output();
$pdf->ezStream();

//write pdf stream to pdf file 
$pdfcode = $pdf->ezOutput();
$fp=fopen('policy.pdf','wb');
fwrite($fp,$pdfcode);
fclose($fp);
fabzster 0 Light Poster

Hi Thanks for the info.

If i change the width in the titlesmall class it just makes that cell smaller it's not going to shift it left, I need it to slot left how will I get that Right?

fabzster 0 Light Poster

ok thanks

Could anyone perhaps tell me how to fix this as is without changinging it
how do I just get the paydate to slot left please:)

Also wouldnt that require Java to detect the browser initially?
What if the clients dont have java loaded this could be an issue

I really would like some assistance in solving my problem without changing it completely

Could any1 help????

fabzster 0 Light Poster

i started off using divs as I mostly use divs, but then I had issues with IE not aligning it the same ....... can anyone assist?

fabzster 0 Light Poster

thanks

Any idea on how to get the paydate left??

fabzster 0 Light Poster

Hi

Thanks for the advice, here is a link and the code below that
http://www.itatpinnacle.com/test/policy_app.php

Form

<html>
<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title></title>
<script type="text/javascript" src="datepickercontrol.js"></script>
<link type="text/css" rel="stylesheet" href="datepickercontrol.css">
<link href="styles.css" rel="stylesheet" type="text/css">

</head>

<body>
				<!-- Change default Date Picker to English -->
				<input type="hidden" id="DPC_TODAY_TEXT" value="today">
				<input type="hidden" id="DPC_BUTTON_TITLE" value="Open calendar...">
				<input type="hidden" id="DPC_MONTH_NAMES" value="['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']">
				<input type="hidden" id="DPC_DAY_NAMES" value="['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']">
				<input type="hidden" id="DPC_DEFAULT_FORMAT" value="YYYY-MM-DD">
<form method="post" action="policy_app_proc.php">
				<div id="form">
				<div id="toperror"><?php print"<font color='#FF0000'><b>{$_SESSION['Imei_unique_error']}</b></font>";?></div>
				<div id="logo">
				<img src="images/24hr.jpg"/>
				</div>
				<div id="top_text">
				Insurer: Constantia Insurance Company Ltd * Reg. No. 1952/001514/06 * VAT No. 4920108935 * FSP No. 31111<br>
				Broker: Pinnacle Marketing (Pty) Ltd * Reg No. 1997/007463/07 * VAT No. 4760167744 * FSP No. 15017<br>
				Underwriting Manager: Administration Plus (Pty) Ltd * Reg. No. 2004/023852/07 * Vat No. 4190243008 * FSP No. 36841
				</div>
				<div id="policy_number">
				POLICY NUMBER <input type="text" name="PolicyNumber" style="color: <?php print $TextColour;?>" value="<?php print $_SESSION['PolicyNumber'] ;?>" id="PolicyNumber" style="border:0;" readonly />
				</div>
<?php
$TextColour = "#000000";
?>			
	<table>
		<tr>
			<td>
				<div class="bar">
				THIS SCHEDULE BECOMES A TAX INVOICE WHEN THE AMOUNT REQUESTED HAS BEEN PAID
				</div>
			</td>
	    </tr>
	</table>
	
	<table>
		<tr>
			<td class="title">Dealer Code</td>
			<td><input name="DealerCode" type="text" id="DealerCode" style="color: <?php print $TextColour;?>" value="<?php print $_SESSION['DealerCode'];?>" size="6" readonly/></td>
			<td class="title"><p style="background-color: <?php print $ConsultantName_error;?>">Consultants Name</td>
			<td><input name="ConsultantName" type="text" id="ConsultantName" tabindex=1 style="color: <?php print $TextColour;?>" value="<?php print $_SESSION['ConsultantName'] ;?>" size="15"/></td>
			<td class="title"><p style="background-color: <?php print $ConsultantSurname_error;?>">Consultants Surname</td> …
fabzster 0 Light Poster

Hi

I am creating a web form but seem to have a problem with my table

I have attached the form and css file but renamed the styles.css to styles.txt to allow me to upload it

My problem is I cannot get the paydate to slot left, I have tried to use <td colspan="">
but dont get the desired results.

I have also attached a screenshot

Thanks :)

fabzster 0 Light Poster

Hi

Normally I would use the mysql_fetch_array command to get vallues from a DB array to print in seperate tables like below:

echo "<table width=\"100%\" border=\"1\"body bgcolor=\"#ffffff\"align=\"center\"text=\"#ffffff\">";
echo "<th>THUMBNAIL</th><th>NAME</th><th>SIZE</th><th>LOCATION</th>";

while($r = mysql_fetch_array($TagSearch))
{
$Code = $r["Code"];
$Name = $r["Name"];
$Size = $r["Size"];
$ImgPath = $r["ImgPath"];
$PurchaseDate = $r["PurchaseDate"];
$StartCycle = $r["StartCycle"];
$CycleLength= $r["CycleLength"];
$Location = $r["Location"];
$Status = $r["Status"];
$idClient = $r["idClient"];
$ShipTo = $r["ShipTo"];
$Medium = $r["Medium"];

echo "<tr>";
print "<td align='center'><a href=art.php?Code={$Code}><img src='{$ImgPath}' height=75 width=75 border='0' /></a></td><td align='center'>$Name</td><td align='center'>$Size</td><td align='center'>$Location</td>";
echo "</tr>";

How would I go about doing the same thing with a normal array
I tried:

echo "<table width=\"100%\" border=\"1\"body bgcolor=\"#ffffff\"align=\"center\"text=\"#ffffff\">";
echo "<th>CODES</th><th>THUMBNAIL</th><th>NAME</th><th>SIZE</th><th>MEDIUM</th><th>PRICE</th>";


while($r = current($_SESSION["Cart"]))
{
$Code = $r["Code"];
$ImgPath = $r["ImgPath"];
$Name = $r["Name"];
$Size = $r["Size"];
$Price = $r["Price"];
$Medium = $r["Medium"];

echo "<tr>";
print "<td align='center'>$Code</td><td align='center'><a href=art.php?Code={$Code}><img src='{$ImgPath}' height=75 width=75 border='0' /></a></td><td align='center'>$Name</td><td align='center'>$Size</td><td align='center'>$Medium</td><td align='center'>$Price</td>";
echo "</tr>";

Now all that does is print the first value in the array over and over.

I would love to use a method close to the first one to do this.

Any suggestions?

fabzster 0 Light Poster

Hi

I have a query which i run to give me the monthly amount of money that needs to get loaded to our consultants cards.

Our system has changed and I need to get the same data but differently

The query needs to join three tables consultants,voucher,gift_cards.

The only difficulty I have is that in the gift card table the consultants may have more than one card number assigned to them as they may have lost thier previous card and been issued a new one, we keep the details of all cards for a history.

when I run the query I need only the latest card number to be displayed -(There is a column date_added) normally i would use

SELECT * FROM gift_cards WHERE id_number='{$id_number}' group by date_issued DESC LIMIT 0,1"

How do i apply this to my JOIN Query Below?

SELECT voucher.value
     , voucher.id_number
     ,cellc.name
     ,cellc.surname
     ,cellc.cell_number
     ,cellc.register_status
     ,cellc.store_id
     ,cards.card_number
     ,cards.issue_number
  FROM voucher
LEFT OUTER
  JOIN ( SELECT id_number
              ,name, surname, cell_number, register_status,store_id
           FROM consultants
         GROUP
             BY id_number ) AS cellc
    ON voucher.id_number = cellc.id_number
LEFT OUTER
  JOIN ( SELECT id_number
              ,card_number, issue_number
           FROM gift_cards
         GROUP
             BY id_number, date_issued) AS cards
    ON voucher.id_number = cards.id_number
WHERE date_added="2010-03-01"

I have tried adding the highlighted portion below but it doesnt work, I assume its trying to limit the value for everything

SELECT voucher.value
     , voucher.id_number
     ,cellc.name
     ,cellc.surname
     ,cellc.cell_number
     ,cellc.register_status
     ,cellc.store_id
     ,cards.card_number
     ,cards.issue_number
     ,cards.date_issued
  FROM voucher
LEFT OUTER
  JOIN ( SELECT id_number
              ,name, surname, …
fabzster 0 Light Poster

Evidently you missed the entire page about foreach then.

its not that I just dont seem to understand how to apply it to this instance

fabzster 0 Light Poster

not to sound funny or anything i was there

I understand how to get an exact value from an array by index

but dunno how to iterate through them

I can do it with a mysql_fetch_array

Am I missing something ?

fabzster 0 Light Poster

Hi
I have an xml file which i get data from using the simplexml_load_file function
I then grab values and store them in variables

now the thing is that the amount of games displayed will be different

I need to grab the values from them with a while loop or something

If it where mysql i would go about using the following method

while($r=mysql_fetch_array($query))
{
$idorder=$r["idorder"];
}

How could I go about using the same type of method in this scenario?

Bear in mind my skillz are limited
Portion of xml file :

[RecentGames] => SimpleXMLElement Object
        (
            [XboxUserGameInfo] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3a%60m%2fl%3b%7c%03
                                    [Name] => Call of Duty: WaW
                                    [TotalAchievements] => 56
                                    [TotalGamerScore] => 1250
                                    [Image32Url] => http://tiles.xbox.com/tiles/7M/zf/02dsb2JgbA9ECgQJGgYfVl4gL2ljb24vMC84MDAwIAABAAAAAPzwzPM=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/g2/Lr/1Gdsb2JhbC9ECgQJGgYfVl4gL2ljb24vMC84MDAwAAAAAAAAAPvEYpw=.jpg
                                )

                            [LastPlayed] => 2009-07-21T12:29:14+00:00
                            [Achievements] => 13
                            [GamerScore] => 200
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3a%60m%2fl%3b%7c%03&compareTo=XENNON187
                        )

                    [1] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3a%60m%2fl4%07%02
                                    [Name] => Call of Duty 4
                                    [TotalAchievements] => 37
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/3g/9G/0Wdsb2JgbA9ECgQJGgYfWSpVL2ljb24vMC84MDAwIAABAAAAAP5pD8E=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/sa/Fy/1mdsb2JhbC9ECgQJGgYfWSpVL2ljb24vMC84MDAwAAAAAAAAAPldoa4=.jpg
                                )

                            [LastPlayed] => 2009-07-19T17:32:03+00:00
                            [Achievements] => 28
                            [GamerScore] => 610
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3a%60m%2fl4%07%02&compareTo=XENNON187
                        )

                    [2] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3bei*h%3eys
                                    [Name] => Rainbow Six® Vegas 2
                                    [TotalAchievements] => 47
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/tl/JM/0mdsb2JgbA9ECgUNGgMfVl9UL2ljb24vMC84MDAwIAABAAAAAP1jUqk=.jpg
                                    [Image64Url] => 
       
fabzster 0 Light Poster

Hi

Im not sure if i need a join here, i cant seem to grasp the concept of joins really batteling with this

I allocate points to id numbers in the points table and i have a list of all id numbers in the consultants table

the id numbers only exist in the points table if points where allocated to them

I would like to be able to see what consultants did not earn any points in a specific date range eg a month. so I would like a list of all the missing Id numbers in the points table for a specific month

SELECT consultants.name
, consultants.surname
, consultants.cell_number
, consultants.id_number
FROM consultants
LEFT OUTER
JOIN ( SELECT id_number
FROM points where date_added between '2008-01-01' and '2008-01-30'
GROUP
BY id_number ) as pts
ON pts.id_number = consultants.id_number

this only shows me the consultants that have points in the month

I would really appreciate some help

fabzster 0 Light Poster

Hi

I found the answer on another forum hope this helps someone out

SELECT consultants.name
     , consultants.surname
     , consultants.cell_number
     , consultants.register_status
     , consultants.id_number
     , pts.pts_added as points_added
     , ords.pts_cost as points_cost
  FROM consultants
LEFT OUTER
  JOIN ( SELECT id_number 
              , SUM(points_added) AS pts_added
           FROM points
         GROUP
             BY id_number ) AS pts
    ON pts.id_number = consultants.id_number
LEFT OUTER
  JOIN ( SELECT id_number 
              , SUM(points_cost) AS pts_cost
           FROM orders
         GROUP
             BY id_number ) AS ords
    ON ords.id_number = consultants.id_number