Jump to content

warrenk

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Posts posted by warrenk

  1. Can I use a CASE statement in a SET?  Or is this not possible?

     

    update ix_spc_product

    set

    Desc6 = CHAR(@FISCAL_MONTH),

    Value1 = @T_UNITS_SOLD_LM,

    Value2 = @T_DOLLARS_SOLD_LM,

    Value3 = (@T_DOLLARS_SOLD_LM - @T_COST_LM),

    Case @T_DOLLARS_SOLD_LM

    WHEN 0

    Value4 = 0

    ELSE

    Value4 = (@T_DOLLARS_SOLD_LM - @T_COST_LM) / @T_DOLLARS_SOLD_LM

    END

    Value5 = @T_UNITS_SOLD_6M,

    Value6 = @T_DOLLARS_SOLD_6M,

    Value7 = (@T_DOLLARS_SOLD_6M - @T_COST_6M),

    Value8 = (@T_DOLLARS_SOLD_6M - @T_COST_6M) / @T_DOLLARS_SOLD_6M,

    Value9 = @T_UNITS_SOLD_12M,

    Value10 = @T_DOLLARS_SOLD_12M,

    Value11 = (@T_DOLLARS_SOLD_12M - @T_COST_12M),

    Value12 = (@T_DOLLARS_SOLD_12M - @T_COST_12M) / @T_DOLLARS_SOLD_12M,

    Value13 = @T_UNITS_SOLD_LY,

    Value14 = @T_DOLLARS_SOLD_LY

     

    where  ID = @ITEM_NUMBER

  2. I have a SQL that has divide by zero errors.  Is there anyway to prevent this?

     

    update ix_spc_product

    set

    Desc6 = CHAR(@FISCAL_MONTH),

    Value1 = @T_UNITS_SOLD_LM,

    Value2 = @T_DOLLARS_SOLD_LM,

    Value3 = (@T_DOLLARS_SOLD_LM - @T_COST_LM),

    Value4 = (@T_DOLLARS_SOLD_LM - @T_COST_LM) / @T_DOLLARS_SOLD_LM,

    Value5 = @T_UNITS_SOLD_6M,

    Value6 = @T_DOLLARS_SOLD_6M,

    Value7 = (@T_DOLLARS_SOLD_6M - @T_COST_6M),

    Value8 = (@T_DOLLARS_SOLD_6M - @T_COST_6M) / @T_DOLLARS_SOLD_6M,

    Value9 = @T_UNITS_SOLD_12M,

    Value10 = @T_DOLLARS_SOLD_12M,

    Value11 = (@T_DOLLARS_SOLD_12M - @T_COST_12M),

    Value12 = (@T_DOLLARS_SOLD_12M - @T_COST_12M) / @T_DOLLARS_SOLD_12M,

    Value13 = @T_UNITS_SOLD_LY,

    Value14 = @T_DOLLARS_SOLD_LY

     

    where  ID = @ITEM_NUMBER

  3. I have a PHP page that runs a SQL after the submit button is pressed. The SQL is a insert. When I run the SQL from PHPMYADMIN, the SQL works fine. When I submit the SQL from the PHP page, it looks like the SQL times out. The SQL does take a little while to run. Is there anyway to change my page so it doesn't time out?

     

    Thanks!

    Warren

  4. I have two tables in a one (master) to many (detail) relationship.  Is there anyway to select this as a one-to-one relationship?  I would use DISTINCT, but one of the fields I select in the detail file is not unique.  So even with the DISTINCT, it always selects multiple detail records for each master.

     

    I just want one occurance of the detail record.

     

    Thanks,

    Warren

     

  5. I know there is a way to limit the size of a uploaded file.  Is there a way to put a size limit on the folder where the file is been uploaded? 

     

    if($_POST['Upload']) {

    $target_path = "/nornet/portal/vendor_images/";

    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

    $_FILES['uploadedfile']['tmp_name'];

     

    $target_path = "/nornet/portal/vendor_images/";

    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

     

    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {

    echo "<b>The file ".  basename( $_FILES['uploadedfile']['name']). " has been uploaded</b><br><br>";

    } else{

    echo "</b>There was an error uploading" .  basename( $_FILES['uploadedfile']['name']). "the file, please try again!</b><br><br>";

    }

    }

     

    echo("<form enctype='multipart/form-data' action='' method='POST'>");

    echo("Upload File: <input name='uploadedfile' type='file'><br>");

    echo("<input type='submit' name='Upload' value='Upload'>");

    echo("</form>");

  6. I am trying to determine if the Upload button is pressed.  When it is pressed, I tried to display a message.  The message never displays.  How can I determine if the Upload button is pressed?     

     

    echo("<form enctype='multipart/form-data' action='' method='POST'>");

    echo("<input type='hidden' name='MAX_FILE_SIZE' value='100000' />");

    echo("Choose a file to upload: <input name='uploadedfile' type='file' /><br />");

    echo("<input type='submit' name='Upload' value='Upload'>");

    echo("</form>");

           

    if(isset($Upload)){ echo "button pressed";}

  7. I am trying to insert records from tableA into tableB if the records do not exist in tableB.  Here is my sql statement...

     

    INSERT INTO str_a1table2( `brands_url` , `brand_name` , `product_url` , `product_name` , `price` )

    SELECT `str_a1table1.brands_url` , `str_a1table1.brand_name` , `str_a1table1.product_url` , `str_a1table1.product_name`

    FROM str_a1table1

    WHERE str_a1table1.brands_url <> str_a1table2.brands_url

    AND str_a1table1.brand_name <> str_a1table2.brand_name

    AND str_a1table1.product_url <> str_a1table2.product_url

    AND str_a1table1.product_name <> str_a1table2.product_name

     

    I keep getting syntax errors.  Any help greatly appreciated!

     

    Thanks,

    Warren

  8. if($_SERVER['REQUEST_METHOD']=='POST') {

      $a=$_POST['checkbox'];

      echo $a;

      echo "<br>";

      print_r($a);

    }

     

    Here are the results:

     

    Array  <==========results of echo $a

    Array ( [0] => 27292181.jpg )  <=========results of print_r($a)

     

    The value I am looking for is the file name (ie. 27292181.jpg).

     

    Thanks for any help,

    Warren

  9. I am trying to view the value of a checkbox.  When I use the code below, I get the value with extra information

     

    if($_SERVER['REQUEST_METHOD']=='POST') {

        $a=$_POST['checkbox'];

        print_r($a);

    }

     

    The value I am getting from the above code - 'Array ( [0] => mm_r.gif)'

     

    ....I just want the actual value - 'mm_r.gif'

  10. I am trying to strip data from a URL parameter into a variable.

    example:
    www.website.com/product.php?id=redwidgit--1
    www.website.com/product.php?id=bluewidgit--2
    www.website.com/product.php?id=greenwidgit--3

    What I am trying to extract is the number at the end of the parameter (ie. 1,2,3).  The number is always at the end of the parameter and it is after two dashes ('--').

    Any help greatly appreciated!

    Thanks,
    Warren
  11. I tried the code...

    <?php

    if ($suppid == "" || $compid == "")
    $link = "http://www.suppsearch.com";
    else
    $link = "http://www.suppsearch.com";

    header("Location: ".$link);
    exit;

    ?>

    Now the script just shows up on the page.  I think I may try a different host.

    http://www.suppsearch.com/product.php

    Warren
  12. I don't know what I am doing wrong.  ??? I tried going to my page from a different computer (in case my redirect was being blocked) and still nothing.

    By the way here is the page...

    http://www.suppsearch.com/product.php

    The code is now...

    <?php
    if ($suppid == "" or $compid == "")
    {$link = "http://www.suppsearch.com"}
    else
    {$link = "http://www.suppsearch.com"}

    header("Location: $link");
    exit;
    ?>
  13. I am trying to perform a redirect with the following code...

    <?php
    if ($suppid == "" or $compid == "")
    {$link = "http://www.yahoo.com";}
    else
    {$link = "http://www.yahoo.com";}
    endif

    header("Location: $link");
    exit;
    ?>

    When I run the page, it just sits on a blank screen.  Am I doing something wrong?  I know I have the same URL in my IF condition, this is for testing purposes only.

    Thanks for any help!
    Warren
  14. I am trying to create a 2 column table and keep getting a error...

    Parse error: parse error, unexpected T_LNUMBER, expecting ',' or ';' in /home/reviews/public_html/brand1.php on line 16

    The line in error is:
    echo "<table width="180" border="1" cellspacing="2" cellpadding="0">";

    Here is some of the code...

    $result = mysql_query("select * from brands");

    $count = 1;
    $column = 1;

    echo "<table width="180" border="1" cellspacing="2" cellpadding="0">";

    //grab all the content
    while($r=mysql_fetch_array($result))
    {
    // first column display
    if ($column == 1)
    {

    //field is the column in your table
    printf("<tr><td>%s</td>",$r["brand_name"]);
    }

    else{
    //second column display 
    printf("<td>%s</td></tr>",$r["brand_name"]);
    }

    $count += 1;

    $column = $count % 2;
    }

    echo "</table>";
×
×
  • 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.