Jump to content

mazman13

Members
  • Posts

    156
  • Joined

  • Last visited

    Never

Posts posted by mazman13

  1. Will something like this work to create an array in a loop?

     

     $query = "SELECT DISTINCT writer FROM data";
    $result = mysql_query($query)
    	or die ("Can't do anything with the query!");
    while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
    {
    extract($row);
    $servicewriters = array($writer);	
    }
    echo"$servicewriters[1]";
    

  2. I have two things that should show up. Laszlo and Dusty. When I add the 2nd query it only adds the 1st one on the table. Laszlo. Is it conflicting with each other? Any way to get the same result with something else?

     

    	
     $query = "SELECT DISTINCT writer FROM data";
    $result = mysql_query($query)
    	or die ("Can't do anything with the query!");
    while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
    {
    extract($row);
    	echo"$writer<br>";
    $query = "SELECT COUNT(quality) AS twriter FROM data WHERE writer='$writer' AND date BETWEEN '$year-$month-00' AND 			'$year-$month-32' ";
    $result = mysql_query($query)or die(mysql_error());
    while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
    	{
    extract($row);
    echo"$writer - $twriter";
    	}
    }
    

  3. I'm gonna go ahead and post my entire code for the report, so if you guys know anything to make it easier, you can shoot me your ideas.

    <?php 
    //Get current date
    $month = date("m");
    $year = date("Y");
    
    //Selected date program
    $sel = $_REQUEST["action"];
    if($sel == "view_date")
    	{
    	$month = $_REQUEST['s_month'];
    	$year = $_REQUEST['s_year'];
    	}
    ?>
    <strong><font color="#333333" size="3" face="Arial, Helvetica, sans-serif">Report for <?php echo"$month-$year";?></font></strong>
    <form action="<?php echo $_SERVER['PHP_SELF'] ?>?action=view_date" method="post">
      <p>
        <select name="s_month" id="s_month">
          <option value="01" <?php if ($month == "01") {echo"selected=\"selected\"";}?>>January</option>
          <option value="02" <?php if ($month == "02") {echo"selected=\"selected\"";}?>>February</option>
          <option value="03" <?php if ($month == "03") {echo"selected=\"selected\"";}?>>March</option>
          <option value="04" <?php if ($month == "04") {echo"selected=\"selected\"";}?>>April</option>
          <option value="05" <?php if ($month == "05") {echo"selected=\"selected\"";}?>>May</option>
          <option value="06" <?php if ($month == "06") {echo"selected=\"selected\"";}?>>June</option>
          <option value="07" <?php if ($month == "07") {echo"selected=\"selected\"";}?>>July</option>
          <option value="08" <?php if ($month == "08") {echo"selected=\"selected\"";}?>>August</option>
          <option value="09" <?php if ($month == "09") {echo"selected=\"selected\"";}?>>September</option>
          <option value="10" <?php if ($month == "10") {echo"selected=\"selected\"";}?>>October</option>
          <option value="11" <?php if ($month == "11") {echo"selected=\"selected\"";}?>>November</option>
          <option value="12" <?php if ($month == "12") {echo"selected=\"selected\"";}?>>December</option>
        </select>
        <input name="s_year" type="text" id="s_year" size="4" maxlength="4" />
        <input type="submit" name="Submit" value="Submit" />
      </p>
    </form>
    <strong><font size="3" face="Arial, Helvetica, sans-serif">Shop Approval Rating<br />
    </font></strong>
    <?php
    $user="user";
    $host="localhost";
    $password="";
    $database="database";
    $connection = mysql_connect($host,$user,$password)
    	or die ("Sorry. Something messed up and it couldn't connect to the dumb server.");
    $db = mysql_select_db($database, $connection)
    	or die ("Something is messed up with the database.");
    
    //Collect main total
    $query = "SELECT * FROM data WHERE date BETWEEN '$year-$month-00' AND '$year-$month-32'";
    $result = mysql_query($query)
    	or die ("Can't do anything with the query!");
    $total = mysql_num_rows($result);
    $maintotal = ($total * ;
    
    //Overall GREETED rating
    $query = "SELECT COUNT(greeted) AS y_greet FROM data WHERE greeted='Y' AND date BETWEEN '$year-$month-00' AND '$year-$month-32'";
    $result = mysql_query($query)or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    extract($row);
    $total_greet = number_format(($y_greet * 100 / $total),1)."%";
    
    //Overall QUALITY rating
    $query = "SELECT COUNT(quality) AS y_qual FROM data WHERE quality='Y' AND date BETWEEN '$year-$month-00' AND '$year-$month-32'";
    $result = mysql_query($query)or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    extract($row);
    $total_qual = number_format(($y_qual * 100 / $total),1)."%";
    
    //Overall CLEANLINESS rating
    $query = "SELECT COUNT(cleanliness) AS y_clean FROM data WHERE cleanliness='Y' AND date BETWEEN '$year-$month-00' AND '$year-$month-32'";
    $result = mysql_query($query)or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    extract($row);
    $total_clean = number_format(($y_clean * 100 / $total),1)."%";
    
    //Overall SERVICE rating
    $query = "SELECT COUNT(service) AS y_serv FROM data WHERE service='Y' AND date BETWEEN '$year-$month-00' AND '$year-$month-32'";
    $result = mysql_query($query)or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    extract($row);
    $total_serv = number_format(($y_serv * 100 / $total),1)."%";
    
    //Overall INFORMED rating
    $query = "SELECT COUNT(informed) AS y_info FROM data WHERE informed='Y' AND date BETWEEN '$year-$month-00' AND '$year-$month-32'";
    $result = mysql_query($query)or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    extract($row);
    $total_info = number_format(($y_info * 100 / $total),1)."%";
    
    //Overall PROMISED rating
    $query = "SELECT COUNT(promised) AS y_prom FROM data WHERE promised='Y' AND date BETWEEN '$year-$month-00' AND '$year-$month-32'";
    $result = mysql_query($query)or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    extract($row);
    $total_prom = number_format(($y_prom * 100 / $total),1)."%";
    
    //Overall ADDITIONAL rating
    $query = "SELECT COUNT(additional) AS y_add FROM data WHERE additional='Y' AND date BETWEEN '$year-$month-00' AND '$year-$month-32'";
    $result = mysql_query($query)or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    extract($row);
    $total_add = number_format(($y_add * 100 / $total),1)."%";
    
    //Overall REFER rating
    $query = "SELECT COUNT(refer) AS y_refer FROM data WHERE refer='Y' AND date BETWEEN '$year-$month-00' AND '$year-$month-32'";
    $result = mysql_query($query)or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    extract($row);
    $total_refer = number_format(($y_refer * 100 / $total),1)."%";
    
    //TOTAL Overall Shop approval
    $stotal = $y_add + $y_qual + $y_clean + $y_serv + $y_info + $y_prom + $y_add + $y_refer;
    $shoptotal = number_format(($stotal * 100 / $maintotal),1)."%";
    echo "<strong><font size=\"5\" face=\"Arial, Helvetica, sans-serif\">$shoptotal</font></strong>";
    ?><br /><br />
    <br />
    <font face="Arial, Helvetica, sans-serif"><strong>Shop Approval Breakdown<br />
    </strong></font>
    <table width="100%" border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td width="87%" valign="middle"><table width="75%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="12%" valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif"><?php echo"$total_greet"; ?></font></strong><Br />
    	<img src="images/greeting.gif"><br />
    	<?php
    		$i = 1;
    while ($i <= $total_greet) {
    echo"<img src=\"images/greeting.gif\"><br>";   
    $i++;}?>		</td>
            <td width="11%" valign="bottom">
    	<strong><font size="1" face="Arial, Helvetica, sans-serif"><?php echo"$total_qual"; ?></font></strong><Br /><img src="images/quality.gif"><br />
    	<?php
    		$i = 1;
    while ($i <= $total_qual) {
    echo"<img src=\"images/quality.gif\"><br>";   
    $i++;}?></td>
            <td width="11%" valign="bottom">
    	<strong><font size="1" face="Arial, Helvetica, sans-serif"><?php echo"$total_clean"; ?></font></strong><Br /><img src="images/clean.gif"><br /><?php
    		$i = 1;
    while ($i <= $total_clean) {
    echo"<img src=\"images/clean.gif\"><br>";   
    $i++;}?></td>
            <td width="10%" valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif"><?php echo"$total_serv"; ?></font></strong><Br /><img src="images/service.gif"><br />
              <?php
    		$i = 1;
    while ($i <= $total_serv) {
    echo"<img src=\"images/service.gif\"><br>";   
    $i++;}?></td>
            <td width="12%" valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif"><?php echo"$total_info"; ?></font></strong><Br /><img src="images/info.gif"><br />
              <?php
    		$i = 1;
    while ($i <= $total_info) {
    echo"<img src=\"images/info.gif\"><br>";   
    $i++;}?></td>
            <td width="11%" valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif"><?php echo"$total_prom"; ?></font></strong><Br /><img src="images/promised.gif"><br />
              <?php
    		$i = 1;
    while ($i <= $total_prom) {
    echo"<img src=\"images/promised.gif\"><br>";   
    $i++;}?></td>
            <td width="10%" valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif"><?php echo"$total_add"; ?></font></strong><Br /><img src="images/additional.gif"><br />
              <?php
    		$i = 1;
    while ($i <= $total_add) {
    echo"<img src=\"images/additional.gif\"><br>";   
    $i++;}?></td>
            <td width="16%" valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif"><?php echo"$total_refer"; ?></font></strong><Br /><img src="images/refer.gif"><br />
              <?php
    		$i = 1;
    while ($i <= $total_refer) {
    echo"<img src=\"images/refer.gif\"><br>";   
    $i++;}?></td>
            <td width="7%"> </td>
          </tr>
          <tr>
            <td valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif">SATISFIED</font></strong></td>
            <td valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif">QUALITY</font></strong></td>
            <td valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif">CLEAN</font></strong></td>
            <td valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif">SERVICE</font></strong></td>
            <td valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif">INFORMED</font></strong></td>
            <td valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif">PROMISED</font></strong></td>
            <td valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif">RETURNS</font></strong></td>
            <td valign="bottom"><strong><font size="1" face="Arial, Helvetica, sans-serif">REFER</font></strong></td>
               </tr>
        </table></td>
      </tr>
    </table>
    <?php 
    //Service writer stats
    
    $array = file("updates/writers.txt");
    sort($array);
    foreach ($array as $writer) {
    $writer = strip_tags($writer);
    	if($writer != "--SELECT--")
    	{
    	$query = "SELECT COUNT(quality) AS twriter FROM data WHERE writer='$writer' AND date BETWEEN '$year-$month-00' AND 		'$year-$month-32' ";
    $result = mysql_query($query)or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    extract($row);
    echo"$writer - $twriter";
    
    	}
    
    }
    
    
    
    ?>
    

     

     

    And here is the mock data I have in my database to make this happen...I didn't have anytime to clean it up. But maybe you can get some ideas out of it.:

     

    ID 	fname 	lname 	phone 	ro 	writer 	tech 	comment 	date 	time 	greeted 	quality 	cleanliness 	service 	informed 	promised 	additional 	refer 	insurance 	recommend 	source 	paysource
    Edit 	Delete 	35 	  	  	-- 	  	Dusty 	--SELECT--
      	2007-10-29 00:00:00 	8 	Y 	Y 	Y 	Y 	Y 	Y 	N 	Y 	  	  	--SELECT--
    --SELECT--
    Edit 	Delete 	34 	  	  	-- 	dsad 	Dusty 	--SELECT--
      	2007-10-29 00:00:00 	8 	Y 	Y 	Y 	Y 	Y 	Y 	N 	Y 	X 	X 	--SELECT--
    --SELECT--
    Edit 	Delete 	33 	  	  	-- 	  	Laszlo 	--SELECT--
      	2007-10-29 00:00:00 	7 	Y 	Y 	Y 	Y 	Y 	Y 	N 	Y 	N 	N 	--SELECT--
    --SELECT--
    Edit 	Delete 	32 	gfdgfdgfd 	  	-- 	gdfgdf 	Dusty
    --SELECT--
      	2007-10-29 00:00:00 	7 	Y 	Y 	Y 	Y 	N 	Y 	Y 	Y 	Y 	Y 	--SELECT--
    --SELECT--
    Edit 	Delete 	31 	  	  	-- 	  	Laszlo 	--SELECT--
      	2007-10-29 00:00:00 	6 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	--SELECT--
    --SELECT--
    Edit 	Delete 	30 	  	  	-- 	  	Dusty 	--SELECT-- 	  	2007-10-29 06:47:00 	18 	Y 	Y 	Y 	N 	Y 	Y 	Y 	Y 	  	  	--SELECT-- 	--SELECT--
    Edit 	Delete 	29 	  	  	-- 	  	Dusty
    --SELECT--
      	2007-10-26 00:00:00 	18 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	  	  	--SELECT--
    --SELECT--
    Edit 	Delete 	28 	  	  	-- 	  	Dusty
    --SELECT--
      	2007-10-26 00:00:00 	18 	Y 	Y 	Y 	Y 	Y 	Y 	N 	Y 	  	  	--SELECT--
    --SELECT--
    Edit 	Delete 	27 	  	  	-- 	  	Dusty
    --SELECT--
      	2007-10-26 00:00:00 	18 	Y 	Y 	Y 	Y 	Y 	Y 	N 	Y 	  	  	--SELECT--
    --SELECT--
    Edit 	Delete 	25 	  	  	-- 	  	Dusty
    --SELECT--
      	2007-10-26 00:00:00 	18 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	  	  	--SELECT--
    --SELECT--
    Edit 	Delete 	26 	  	  	-- 	  	Dusty
    --SELECT--
      	2007-10-26 00:00:00 	18 	Y 	Y 	Y 	Y 	Y 	Y 	N 	Y 	  	  	--SELECT--
    --SELECT--
    Edit 	Delete 	36 	  	  	-- 	  	Laszlo
    --SELECT--
      	2007-10-29 00:00:00 	8 	Y 	Y 	Y 	  	  	  	  	  	  	  	--SELECT--
    --SELECT--
    

     

     

  4. If you want to get a better idea of what I am looking for you can go here:

    collisionspecialiststx.com/csi

     

    We are making a breakdown of customer service approvals for a bodyshop.

     

    Its going to look nicer...it's just a rough draft right now.

     

    Right now everything works. We can get an overall approval rating for the shop, and a breakdown of the categories and graphs.

     

    Now we are trying to take it a few steps further...trying to get an overall approval rating for the service writers, insurance, and techs. You can see where we are getting all of our data from by clicking the "Add Report" link.

    Thanks

     

  5. I am trying to grab info from a text file, and with that information, I will grab info from a table and display it.

     

    I do not want to show --SELECT-- so thats why the IF statement is there.

    For some reason it will still show --SELECT-- but doesn't read it as such.

    If I try to say:

     

    $writers == "--SELECT--"

    it wont see it. Why does it do it?

     

    writers.txt contains:

    --SELECT--

    Dusty

    Laszlo

     

    $text = file_get_contents("updates/writers.txt");
    $array = explode("\n",$text);
    sort($array);
    foreach ($array as $writer) {
    $writer = strip_tags($writer);
    echo"$writer";
    	if($writer != "--SELECT--")
    	{
    	$query = "SELECT COUNT(quality) AS twriter FROM data WHERE writer='$writer' AND date BETWEEN '$year-$month-00' AND 		'$year-$month-32' ";
    $result = mysql_query($query)or die(mysql_error());
    $row = mysql_fetch_assoc($result);
    extract($row);
    echo"$writer - $twriter";
    
    	}
    
    }
    

     

     

  6. My query looks like this.

     

    $query = "SELECT COUNT(quality) AS twriter FROM data WHERE quality='Y' AND date BETWEEN '$year-$month-00' AND '$year-$month-32' AND writer='Dusty'";

    $result = mysql_query($query)or die(mysql_error());

    $row = mysql_fetch_assoc($result);

    extract($row);

    echo"$twriter";

     

    It should return with the number 6. But it returns 0. If I delete the Yellow part it brings back 7. Which is correct.

     

    What is wrong with the query? Everything is correct. I have 6 rows with the writer Dusty. If I update a row, it will timestamp that row and will show on the query. Could there be something wrong with the dates? It seems to only pull it if it was created on todays date.

     

  7. $connection = mysql_connect($host,$user,$password)

    or die ("Sorry. Something messed up and it couldn't connect to the dumb server.");

    $db = mysql_select_db($database, $connection)

    or die ("Something is messed up with the database.");

     

    $query = "SELECT greeted,quality,cleanliness,service,informed,promised,additional,refer FROM data";

    $result = mysql_query($query)

    or die ("Can't do anything with the query!");

    $total = mysql_num_rows($result);

    while ($row = mysql_fetch_array($result,MYSQL_ASSOC))

    {

    extract($row);

    .....and this is where im stuck

  8. Trying to make a drop down box like this example:

     

    Dog

    Cat

    Bird

     

    But sometimes I will need to update it...and add/remove names from the list. I want to do it fast and easy and I don't want to use a MySQL Database. I'd rather use a text file...can that be done?

     

    I would keep the info in a text file and then push it to a drop down box via php and html.

    Let me know if this will work.

     

  9. Well I dont' know how that would work.

     

    Because lets say I have five customers.

     

    1) 35.7%

    2) 93.6%

    3) 99.2%

    4) 100%

    5) 78.4%

     

    I want to talley all of them up for an average for the month. What can I do?

    And how can I do it with a couple of hundred customers a month?

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.