Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Posts posted by joel24

  1. you have to select post_id from ignore, not posts.post_id, as they are seperate queries...

    SELECT Users.id, Posts.post, Users.username, Posts.post_id
    FROM Posts, Users, Friends
    WHERE Posts.username_id = Users.id 
    AND Friends.user_id = $user 
    AND Friends.friend_id = Posts.username_id
    NOT IN (SELECT post_id FROM ignore)
    

     

    .. though that will return the post_id of every ignored post, by any user. you need to change the last select to incorporate the user's id, i.e.

    SELECT Users.id, Posts.post, Users.username, Posts.post_id
    FROM Posts, Users, Friends
    WHERE Posts.username_id = Users.id 
    AND Friends.user_id = $user 
    AND Friends.friend_id = Posts.username_id
    NOT IN (SELECT post_id FROM ignore WHERE user_id=$user)
    

  2. SELECT * FROM post WHERE post_id NOT IN (SELECT post_id FROM ignore)

    though if user_id in the ignore table is the user who ignored the post, you would have something like this... assuming the user id is stored in the session

    SELECT * FROM post WHERE post_id NOT IN (SELECT post_id FROM ignore WHERE user_id='{$_SESSION['user_id']}')

  3. there are a few different ways you can join tables, my favourite is

    SELECT tp.id, tp.content, tc.catname
    FROM tablePost tp
    JOIN tableCategory tc ON tp.categoryid = tc.id
    

     

    have a read up here or on google.

  4. use a session to store the language for the duration of the user's visit to your site and then check if the session is set after you check the get variables (in case they want to change languages again)

    i.e.

    session_start();
    
    if (isset($_GET['lang'])) {
    //add to session
    $_SESSION['lang'] = $_GET['lang'];
    } else if (isset($_SESSION['lang'])) {
    //language is set in session - do nothing.
    } else {
    //default language
    $_SESSION['lang']='en'
    }
    
    // Include the right language file	
    include("lang/{$_SESSION['lang']}.php");
    

     

    *EDIT* you need to ensure session_start(); is located at the top of each PHP script which you want to include the session variables. read up on sessions at the link I put above.

     

  5. the line

    if( isset($_GET['lang']) && use_lang($_GET['lang']) )

    checks to see if any language variables are set in the URL

    You need to pass the $_GET variables when a user clicks on the appropriate language flag

     

    $lang["available_language"] = array(
    	"en" => "English",
    	"es" => "Spanish",
    	"pt" => "Portuguese",
    	"it" => "Italian",	
    );
    
    //you'll have to set the src part to point to the folder where the flags are
    //you'll also have to change index.php to the page name, or look into using a $_SERVER variable to echo the page
    foreach ($lang AS $key=>$value) {
    echo "<a href='index.php?lang=$key'><img src='$key.png' alt='$value' /></a>";
    }
    //foreach will return <a href='index.php?lang=en'><img src='en.png' alt='english' /></a> for the first
    

  6. you could select the next / previous like so?

    i.e.

    SELECT TIMEDIFF((SELECT cil_start_time FROM coc_issue_log WHERE cil_issue_log_id = cil.cil.issue_log_id),(SELECT cil_end_time FROM coc_issue_log WHERE cil_issue_log_id < cil.cil_issue_log_id LIMIT 1)) AS TIMEDIFF, cil_issue_log_id FROM cil_issue_log cil
    

  7. just enclose the values with brackets and seperate with a comma

    INSERT INTO `cork_wall`.`Classified` (
    `id` ,
    `user` ,
    `description` ,
    `link` ,
    `img1` ,
    `published`
    )
    VALUES (NULL , 'corkdjs@gmail.com', 'Hi guys.', '', 'http://munsterweddingdjs.com/images/weddings-in-east-cork.jpg', '0'),
    (NULL , 'email2@gmail.com', 'Hi guys.', '', 'http://munsterweddingdjs.com/images/weddings-in-east-cork.jpg', '0'),
    (NULL , 'email3@gmail.com', 'Hi guys.', '', 'http://munsterweddingdjs.com/images/weddings-in-east-cork.jpg', '0');
    

  8. you need to break the quotation if you echo this way, or use double quotes.

    i.e.

    $string = 'this is a string';
    $single = '<p>the sting is: '.$string.'</p>';
    $double = "<p>the string is: $string</p>";
    
    echo $single . $double;
    

     

    You only need <?php echo $whatever; ?> if the code is not located within PHP <?php ?>

    i.e.

    <?php
    $string = 'this is a string';
    ?>
    
    <html>
    <head>
    </head>
    <body>
    My String: <?php echo $string; ?>
    </body>
    </html>
    

  9. use unix timestamp with modulus for a 50/50 split... timestamp measures the seconds passed since 1st jan 1970, so the ad would change depending on if the seconds were odd or even. i.e. 10001 would be ad1 and 10002 would be ad2. rough 50/50 split.

    $time = time();
    if ($time % 2) {
        echo "ad1";
    } else {
        echo "ad2";
    }
    

  10. But is there a limit to the number of files that can be stored in any one folder?

    No.

     

    Or is there a point when the number of files within the folder mean searching the said folder becomes slow?

    If you're only searching for file name, no.

    You should store the file name, details, author and location in a mysql table and then when someone searches for a file - search the mysql database, return the location from there and return the file using PHP.

  11. sorry, misunderstood your question.

    something like this should work

    $query = 'SELECT * FROM wp_usermeta WHERE meta_key = "wp_1_s2member_custom_fields"';
    $results = mysql_query($query);
    
    $region = array();
    
    while($line = mysql_fetch_assoc($results)) {
    $meta_value = unserialize($line['meta_value']);
    
    $region[$meta_value['county']]++;
    
    };
    
    foreach ($region as $key => $value) {
    echo "Region $key: $value members";
    }
    

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