Jump to content

Canman2005

Members
  • Posts

    669
  • Joined

  • Last visited

    Never

Posts posted by Canman2005

  1. Hi all

     

    I have the following QUERY

     

    SELECT  *
    FROM product_category_associations
    INNER JOIN products ON product_category_associations.product_id = products.id
    AND products.date_available <= '2008-11-05'
    WHERE products.product LIKE '%Sample%'
    AND `december` !=0
    AND product_category_associations.live =1 GROUP BY `linked_id`
    ORDER BY product_category_associations.live DESC

     

    It returns something similar to

     

    `product`        `linked_id`        `live`

    iPod Nano          232                1

    iPod Classic      112                  1

     

    there is one more row in the database, but as it has a `live` value of 0, then it does not display (but for the record that row is)

     

    `product`        `linked_id`        `live`

    iPhone              232                0

     

    If you notice, the 'iPhone' and 'iPod Nano' share the same `linked_id` (232) but because the 'iPhone' has a `live` value of 0 it's not returned in the main QUERY.

     

    How can I alter my QUERY so that if the database finds that any rows with indentical `linked_id` values, and either of them have a `live` value of 0, then they won't display either, so in this case, because the `iPhone` has the same `linked_id` as the `iPod Nano`, but the `iPhone` has a `live` value of 0, then it won't display either of those rows, so if I ran the main QUERY again, it would just return

     

    `product`        `linked_id`        `live`

    iPod Classic      112                  1

     

    Can anyone help?

     

    Thanks

  2. Hi all

     

    I am using

     

    mysql_real_escape_string

     

    when posting any data from a form to a QUERY, but I am getting an increasing number of slashes appearing, sometimes as many as 7 or 8 of them per value.

     

    I am using strip the php strip slashes funtion to remove them, but it does seem to be leaving some values with slashes in them

     

    How can I strip all slashes?

     

    thanks

  3. Okay, I have managed to track down and mod a script, it's

     

    <script type="text/javascript">

    var posx;

    function getMouse(e){

    posx=0;

    var ev=(!e)?window.event:e;//IE:Moz

    if (ev.pageX){//Moz

    posx=ev.pageX+window.pageXOffset;

    }

    else if(ev.clientX){//IE

    posx=ev.clientX+document.body.scrollLeft;

    }

    else{return false}//old browsers

    document.getElementById('myspan').firstChild.data='X='+posx;

    }

    document.onmousemove=getMouse

    </script>

    <span id="myspan"> </span>

     

    This seems to give the X coordinates, but I am having problems doing two things;

     

    1: Attaching it to a form button, so that it only read the X coordinates on that button

     

    2: Also, if you move you mouse quickly from right to left, rather than X coordinate resetting back to 0, it seems to stay on higher numbers, for example, I moved the mouse very fast from right to left and it went from a X coordinate count on the far right of 987 to 123 when it was as far left as it could be. Any reason for that?

     

    Any help would be appricated everyone

  4. Hi all

     

    I have a form button which looks like

     

    <input type="image" src="images/longbar.gif" width="400" height="30"

     

    What I want to try and do is to display (as HTML text) above this button what position the mouse is within the button, so having a number chart going from 1.0  1.1  1.2 .... upto...... 9.8  9.9  10.0

     

    So if someone put their mouse in the middle of this button, it would display 5.0 and if they place it at a 1/4 of the way along, it woud display 2.5 and so on.

     

    Is this possible? Can anyone help me? I'm a total ZERO when it comes to JScripting, so could really do with a hand.

     

    Thanks very very very much

  5. hummm, that didnt seem to work either, so you know my code, I have the following

     

     

                   

    $maxres = mysql_query ("SELECT SUM(score) AS totalScore FROM people GROUP BY name ORDER BY totalScore DESC LIMIT 1");

     

    Which works perfect, then I have the following

     

    $max = mysql_result ($maxres,0);
    
                    $sql = "SELECT name, score, score*100/$max as pc FROM people ORDER BY score DESC LIMIT 10";
                    $res = mysql_query($sql);
                    while (list($name, $score, $pc) = mysql_fetch_row($res))
                    {
    	printf('% (%0.1f<br>', $score, $pc/10);
    	}

     

    Which works and currently goes and returns everything in `score` order with a point score going from

     

    0

    0.1

    0.2

    .........

    9.8

    9.9

    10.0

     

    But what I want to do is to get it to group up anyone with the same `name` but adding their `scores` up and then returning a point score.

     

    Does that help at all?

     

    Thanks very much for all the help so far

  6. Similar to the last question, but I have this QUERY

     

    SELECT name, score*100/$max as pc FROM `people` ORDER BY score DESC

     

    Which basically returns

     

    David 300

    Bryan 200

    David 150

    Susan 120

     

    How can I do the same and count the total score for anyone with the same `name` so the result for that data would be

     

    David 450

    Bryan 200

    Susan 120

     

    But it would need to retain the part of the Query

     

    score*100/$max as pc

     

    as that is used later on in the code to work out an average score, but I need to try and group anyone with the same `name` together but adding up their `score`

     

    sorry its a bit vague

     

    any help would be wicked

     

    thanks

  7. Hi

     

    I have a few questions, but i'll take it one at a time, firstly, have a table called `people` which looks like

     

     

       

    name

       

    score

     

     

       

    David

       

    150

     

     

       

    Bryan

       

    200

     

     

       

    David

       

    300

     

     

       

    Susan

       

    120

     

     

    At the moment i'm using

     

    SELECT MAX(score) FROM `people`

     

    with that data it gives me 300 at the moment.

     

    I want to do the same Query but count duplicates with the same `name`, so if I did this Query then it would return the value 450 as David has 2 entries and added together they eual the highest value.

     

    Any help would be ace

     

    Thanks

     

  8. Hi all

     

    Wondering if someone can help me.

     

    Basically I have a form which has 2 fields

     

    Numbers (which on the form is called `number`)

    Real Number (which on the form is called `real_number`)

     

    I then have a price (which on the form is called `cost`)

     

    What I want to do is if in the number field there is the value 100 and the price value is 5 and someone enters into the real number the value 200, then it would calculate the price at 10

     

    Again, if the number value was 1 and the price was 15 and the real number value was changed to 2 then the price would increase to 30

     

    If for example the number value was 50 and the price was 10 and the real value number was changed to 25 then the price would come out at 5

     

    Does that make sense?

     

    Can anyone help?

×
×
  • 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.