Jump to content

bibby

Members
  • Posts

    171
  • Joined

  • Last visited

    Never

Posts posted by bibby

  1. Use javascript to valiate basic things,
    like wether en email address is really an email address,
    or if the number you products you want to order is an actual interger.

    Use ajax to validate specific things,
    like if your particular email address is in a database.

    [code]
    <script>
    function validate()
    {
    var e = document.getElementById('thing').value;
    if (e == '') {alert('dude, its blank');}
    else if (isNaN(e)) {alert('dude, thats not a number');}
        else {alert('ok, looks good.')}
    }

    <input type="text" id="thing" name="thing">
    <input type="button" onclick="validate();" value="check">
    </script>
    [/code]
  2. That's certainly going to break!
      You can't make requests that fast. Each one is going to listen for a ready state.

    If you had 1000 items, you'd make 1000 server requests in 10ms!
    Of course, it'll break by the second one.

    You should find a way to preallocate those values.
  3. There are a lot of things that you need to look into separately, but nothing you have asked for seems impossible:


    [quote]Im sure this will be a php/mysql/javascript answer, but i think the clever stuff will have to be done in Javascript...[/quote]
        Yeah, if the side frame is never to refresh, but remain aware of it's changing surroundings, then javasctipt is the answer.

    [quote]What I am wanting to do is have 2 frames, one containing some navigation stuff, one containing the main site displayed.  [/quote]
        [i]meh[/i], I don't like that you're using frames, but it should work. The reason why I say so is that you'll need some ajax anyway for your context menu, so why not refetch the whole display frame?

        [quote]What i am looking to do is automatically check the page which is loaded (read the html) and allow me to use the right click (custom context menu?) on hrefs and images within hfrefs to send their value to a database.[/quote]

        Sending values without refreshing will need some ajax. This expects some sort of return (which is the new context menu?), or a brand new display frame.  You can set events to fire on right-click , but mac users might hate you.

      To have the left-frame aware of what's going on, research setAttribute() & getAttribute(), or use a dummy input to store the filename clicked:
    [code]
    <script>
    function addToBucket(url)
    {
          document.getElementById('bucket').value=url;
          // or whatever.setAttribute('active')=url;

          //now do things according to plan   
          processChanges();
    }

    function fetchFromBucket()
    {
        return document.getElementById('bucket').value;
          // or whatever.getAttribute('active');
    }

    function processChanges()
    {
        var activeUrl = fetchFromBucket();
        /**
        // do whatever you need to based on this condition
        **/
    }
    </script>

    <input type="hidden" id="bucket">

    <a href="file1.php" onclick="addToBucket(this.href);">
    <a href="file2.php" onclick="addToBucket(this.href);">
    [/code]
  4. Here's a little something I've been playing with.

    [code]
    <html>
    <script>
    document.onmousemove= function (e){followMouse(e); }


    function followMouse(e) {
    var posx = 0;
    var posy = 0;
    if (!e) var e = window.event;
    if (e.pageX || e.pageY) {
    posx = e.pageX;
    posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
    posx = e.clientX + document.body.scrollLeft
    + document.documentElement.scrollLeft;
    posy = e.clientY + document.body.scrollTop
    + document.documentElement.scrollTop;
    }

    mark(posx,posy)
    }


    function mark(x,y)
    {
    var d = document.getElementById('coords')
    d.value=x+' x '+y;
    d.style.left=parseInt(x+20)+'px';
    d.style.top =parseInt(y+20)+'px';
    }
    </script>

    <input type="text" id="coords" style="position:absolute;top:0px;left:0px;">
    </html>
    [/code]
  5. Let's break down the tasks :

    Javascript is going to do the listening for changes in the dropdown.
    If you preload all the possibilities, js could replace your dropdown too,
    but if you want to fetch it dynamically all the time, you'll want to make an ajax request
    to something like buildNewDropdown.php?conditions=2
  6. I'm hoping that you are using more than one table for that.
    I'm seeing 3 [i]objects[/i] here,  users, things, and transactions.

    [code]
    #table users  ,  allows sellers to also be buyers
    userID |  Role  |  email..|ect..

    #table things, allows sellers to sell many things
    thingID| sellerID | pricePerThing  | numberOfThings

    #table transactions
    transID  | sellerID | buyerID | thingID | agreedPricePerThing | negotiatedNumberOfThings
    [/code]

    Dig ?
  7. No No No.
    The error is here.

    $sql = "SELECT LEFT(websites_url, 1) AS [b]'websites_url_letter'[/b], websites_url
              FROM websites
            WHERE websites_url_letter='$letter'
              ORDER BY websites_url ASC;";

    Drop those quotes.
  8. If you had 3 columns,  [ user, friend, referral ] , you could draw them out sorted any way you want.

    [code]
    Select * from people
    order by referral asc , friend asc
    [/code]

    I imagine person C's record would be
    [code]#user | friend | referral
    #  C        B          A[/code]


    I guess I don't really understand the exact result you are trying to get, but here's some bonus queries anyhow.

    [code]
    # friendliest people
    select count(*) friends , friend
    from people
    group by friend
    order by friends desc


    #most referrals
    select count(*) referrals, referral referring_person
    from people
    group by referral
    having referrals>1
    order by referrals desc
    [/code]
  9. [b]You said:[/b]
    [QUOTE]
    $sql = "
    SELECT * FROM property
    LEFT JOIN image
    ON image.ID_property = property.property_id
    WHERE property_id = ".$_GET['property_id']."
    GROUP BY property_id;";
    [/QUOTE]

    Ok. The thing with left join is that it's going to return the whole of the other table no matter what.
    What you are doing is duplicating a lot of data and eliminating most of it. What the query is asking for is [b]property.*[/b], which for all I know is 25 columns. So, if there were 10 images found, you get 225 more cells than you bargained for.

    You should probably make that process two separate queries, one for the property row, and one the get imageIDs.
    At best, you wouldn't gain much by making it one query, as compared to the hit to the resource it could take if there were more cells.

    something like this
    [code]<?
    if ($_GET['property_id'])
    {
    $id=$_GET['property_id'];

    $getProperty="
    select * from property
    where property_id = '$id'; ";

    if($query=mysql_query($getProperty))
    {
    if( ($n=mysql_num_rows($query)) > 0 )
    {
    //property array
    $property=mysql_fetch_assoc($query);
    print_r($property);

    $getImages="select image_id from image where 1 and ID_property=";

    if($query=mysql_query($getImages))
    {
    //image array
    while($image=mysql_fetch_row($query))
    print_r($image);
    }
    }
    else echo "no property rows returned";
    }
    else echo "getProperty did not run. <!-- ".$getProperty." -->";
    }
    else echo "give me a property_id";
    ?>[/code]

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