Jump to content

adam84

Members
  • Posts

    289
  • Joined

  • Last visited

Posts posted by adam84

  1. Doing it with javascript

     

    <SCRIPT>
    function  changeText( name ){
    document.getElementById('nameDIV').innerHTML = name;
    }
    </SCRIPT>
    
    <body>
    
    <DIV NAME=nameDIV ID=nameDIV></DIV>
    
    <ul>
    <li ONMOUSEOVER=javascript:changeText('Larry')>Larry</li>
    <li ONMOUSEOVER=javascript:changeText('Debra')>Debra</li>
    </ul>
    
    

  2. This deals with Canadian Postal Code, for some reason we have a ton of them.

     

    On my site, I have a search form, where the user enters their seach criteria, they enter in the postal code (X0X 0X0), then they select the distance they wanna search within (10km, 25km, 50km, etc).

     

    When the user submits the form, I collect all the submitted data, and create my sql statement. I then call a function the queries my postal code database and the function returns all the postal codes in an array that are within the distance range (I didnt write the function). For instance I got over 150 different postal codes returned for a simple 25km search.

     

    This is pretty much how my sql statement looks, except each postal code is different. My question is, is this how I should be doing this using the 'IN' or is there another more efficient way of doing thisa dn speeding it up.

     

    SELECT * FROM userProfile WHERE userGender = 'F' AND age > 19 AND age < 31 AND pCode IN (
    'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8')
    

    *Sample query, can post an actual one later, I dont have the files on me

  3. like this?

     

    $sql = "SELECT jos_content.id, jos_content.title, jos_categories.title AS section
    FROM jos_content, jos_categories
    WHERE jos_content.created_by = '$kim' AND jos_content.catid=jos_categories.id";
    
    $results = mysql_query( $sql );
    while( $row = mysql_fetch_array( $results ) ){
       echo " <a href='index.php?option=com_content&view=article&id=".$row['id']."'>".$row['title']."</a>/".$row['section']."<br>";
    }

  4. This is the table structure

     

    Table userPictures:

     

    pictureID - int auto

    userID - int

    relType - int  - a picture can be used in different profiles (we can just use 1)

    pictureLink - varchar  - url of pic

    pictureMain - int    - is this picture the main picture

    pictureGallery - int - is this picture a gallery picture

    picturePrivate - int - is this picture a private picture

    pictureCreated - datetime

     

    Ok, what I want returned is three different things.

    1 - the 'pictureLink' of a 'pictureMain'

    2 - is there at least 1 gallery picture? - Hence the count(pictureID)

    3 - is there at least 1 private picture? - Hence the count(pictureID)

     

     

     

    SELECT pictureLink FROM userPictures, 
    
    (SELECT count(pictureID) FROM userPictures WHERE userID = 11 AND relType = 1 AND pictureGallery = 1 LIMIT 1) as galCount, 
    
    (SELECT count(pictureID) FROM userPictures WHERE userID = 11 AND relType = 1 AND picturePrivate = 1 LIMIT 1) as priCount 
    
    WHERE userID = 11 AND relType = 1 AND pictureMain = 1 LIMIT 1
    

     

  5. 1 - get the pictureLink. I am able to do that

    2 - I want to see if there is at least 1 gallery picture for a certain user and certain relationship

    3 - I want to see if there is at least 1 private picture for a certain user and certain relationship

     

    I can do it in different queries, but I just thought one query would be easier

  6. SELECT pictureLink FROM userPictures, (SELECT count(pictureID) FROM userPictures WHERE userID = 11 AND relType = 1 AND pictureGallery = 1 LIMIT 1) as galCount, 
    (SELECT count(pictureID) FROM userPictures WHERE userID = 11 AND relType = 1 AND picturePicture = 1 LIMIT 1) as priCount 
    WHERE userID = 11 AND relType = 1 LIMIT 1
    

     

    When I run this query, all I get returned is the pictureLink.

    If i ran the last two sub queries, i get a value of 1 returned.

     

    How come, when it is all put together, only the pictureLink row gets returned?

  7. Try this

    function check(n1,n2){
    document.getElementById(n1).checked=true;
            document.getElementById(n2).checked=true;
    
    }

     

    Both n1 and n2 are variables, so when they are inside quotes, you are not using the variable, but rather just the string or whatever 'n1' and 'n2'.

  8. A question about this topic. I am doing something similar

     

    You are storing different 'issues' as such '1,15,21,32,55'

    How would you do about searching for all the records that have the issue '15'.

     

    You cannot just go, because your issues column is more then likely a varchar, so 15 <> '1,15,21,32,55'

    SELECT * FROM table WHERE issues = '15'
    

     

    So how would you go about searching for the all the users who have a certain issue?

  9. I have a column (text) where the user enters like a profile about themselves.

     

    What I want to do is in the search results, I just want to grab the first 100 or so words from that column. Is there an sql function the would just return that or will I ahve to create a php function to do that?

     

    Awesome!

     

    Thanks

  10. I am currently writing an sql query. As of now, I am crossing three different tables and with doing this the sql statement is starting to become quite large. I am just wondering if it would be quicker for me and for the execution time if I were to split up the query into two different queries or is it always best to put everything I need into one big query and let the system do what it needs to do. Thanks

  11. Since that variable $id is a php variable, you can use it when its between the php '<?' '?>' tags. If you try and use it outside of the php tags, then I think you will just get the actually '$id' being passed instead of the '847288'

  12. I have a site where I allow a user to upload x amount of pictures. What I want to do is when a user uploads a picture, I want to add my site's logo to the bottom right side of the picture. Any ideas? I tried to serach in google, but I really had no idea on what exactly you would call this. Thanks.

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