Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Posts posted by joel24

  1. A subquery should work?

     

    $data = mysql_query("SELECT a.*, (SELECT COUNT(posts) FROM YBK_Ads a WHERE a.UID = y.UID) AS postCount FROM YBK_Login y") or die(mysql_error()); 
    while($info = mysql_fetch_array( $data )) { 
    
    
    
    Print "<tr>"; 
    
    Print "<td>".$info['postCount'] . " </td>";
    
    Print "<td>".$info['UID'] . " </td>";
    
    
    
    Print "<td>"."#"."</td>";
    
    
    
    Print "<td>".$info['ID'] . "</td> "; 
    
    
    
    Print "<td>".$info['Allowed'] . "</td> ";
    
    
    
    Print "<td>".$info['pass'] . " </td>";
    
    
    
    Print "<td>".$info['HR'] . " </td>"; } 
    
    ?>
    

  2. i still haven't got my head around what exactly you want to do and how it correlates to your existing code,

    I noticed the field type for DATE, MONTH & YEAR are all INT(11)... unix timestamps I presume? Why do you have date, month & year fields? If they're all unix timestamps aren't they all the same value?

     

    //this query might get you started
    SELECT MAX(amount) FROM rosters GROUP BY MONTH(from_unixtime(date)) ORDER BY date DESC LIMIT 1;

  3. don't really understand what you're trying to achieve, but in terms of getting the most recent you can use

    ORDER BY date DESC//or this to order by section, and then the dates of each entry for the sectionORDER BY section, date DESC

     

     

    also, since DATE is a predefined mysql variable/term you may have to rename this field.

     

    Could you post your mysql table schema (fields, field types etc) and explain what you want to do exactly?

  4. what is

    UPDATE users SET

    doing there?

    if it is a comment, comment it out like so

     

    //UPDATE users SET

     

    if it is a part of an SQL query put it inside a query.

     

    and then the closing bracket on line 13 } - where is the opening bracket?

     

    Post the entire code

  5. maybe try cURL?

    demo here

     

     

    and if you persist on using file() or file_get_contents(), this is written on PHP.net in regards to the file() function link

     

    Tip

     

    A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the List of Supported Protocols/Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

  6. substr($news, 0, 100) will return the first 100 characters of the $news string, though if you have HTML in that string also, the html is also counted in the 100 characters.

     

    you can strip the tags as I stated before and the other options are quite convoluted, such as counting the HTML characters in the string then adding this to the amount of characters to return. To my knowledge there is no inbuilt function to count HTML characters, though substr_count() would count the amount of occurrences of a tag, then you would have to multiply that by the amount of characters in said tag... then do this for every tag and add it to 100 in the substr($news, 0, 100) function.

     

    I would just use strip_tags() and show a 100 character teaser, then have a link so the user can view the entire article.

  7. rather than having that foreach loop and individually adding each line to a variable, you can use file_get_contents() which will put the contents into a single string.

     

    something like this may work... I'm not all too skilled with regular expressions though someone else may help you.

    //haven't tested this yet, but good luck
    
    $pageHtml = file_get_contents("http://www.bbc.co.uk/");
    
    //get position of <body> tag
    $openingTag = stripos($pageHtml, "<body>");
    
    //position of </body> tag
    $closingTag = stripos($pageHtml, "</body>");
    
    //get length of body tag by position closing minus position starting tag (+6 for <body> tag characters)
    $length = $closingTag - ($openingTag + 6);
    
    $bodyHTML = substr($pageHTML, $length);
    
    echo $bodyHTML;
    

  8. just start with a simple form and use

    print_r($_POST);

    untill you get the values posting.

     

    Also in your HTML code you have a table inside a table inside a table... I would change this to just be one table and have the <form> tags outside the table, much easier to diagnose any HTML problems.

    i.e.

     

    <form><table><tr><td></td></tr></table></form>

     

     

    And you are posting the form to "entervalues.php" and from what you've written that page is actually called "enteredvalues.php"

  9. does it print out all the posted values from the form?

    I'm baffled as to what route your page is taking...

     

    You have a separate login form (main_login.php)? that is posted to where?

    and then the user is meant to see login_success when?

     

    the lines I said

    print_r($_POST);
    exit();

    should only be used whilst you're diagnosing this problem, they will print out any values posted to the page from a form.

  10. for GET you can point to the passed variables with

    $_GET['variableName']; 
    //in your example 
    echo $_GET['fname'];
    

     

    what exactly is fname... function name?

    and what do you want to do with this value when you get it on the next page.

     

    $_GET means that variables and data are sent via the url, i.e. www.mydomain.com/index.php?testVariable=Joels, then on index.php $_GET['testVariable'] would equal 'Joels'.

     

    You'll want to use urlencode() and urldecode() to ensure unsafe URL characters are transformed into URL safe characters

     

  11. it's not redirecting back to login_success because your logic tells it to redirect to login_success on a failure.

    $sql="INSERT INTO $tbl_name (firstname, lastname, pnumber, numberactivated,) VALUES ('$firstname','$lastname','$pnumber','$numberactivated')")or die(mysql_error());  
    $r = mysql_query($sql);
    if(!$r) {
    
        $err=mysql_error();
    
        print $err;
    header("location:login_success.php");
        exit();
    }
    

     

    !$r means if $r fails. try this

    $sql="INSERT INTO $tbl_name (firstname, lastname, pnumber, numberactivated,) VALUES ('$firstname','$lastname','$pnumber','$numberactivated')")or die(mysql_error());  
    $r = mysql_query($sql);
    
    //if success, redirec to success page
    if($r) {
    header("location:login_success.php");
    exit();
    } else { //else error
        $err=mysql_error();
    
        print $err;
    
        exit();
    }
    

     

    and as for it not inserting into the mysql, put this bit of code up the top and ensure the form values are being posted to the page

    print_r($_POST);
    exit();
    

     

    you'll obviously want to remove that when the site goes live.

     

  12. you'll want to incorporate a subquery selecting the deductions corresponding to that employee.

    $monthNumber = 32;
    $sql = "SELECT e.employeeDept, e.deptEmployeeRef, e.name, e.wage - (SELECT COUNT(deduction) FROM deductions WHERE deptEmployeeRef = e.deptEmployeeRef AND monthNo = $monthNumber) FROM employees e"
    

     

  13. at first i was trying to collect random emails from random websites using a search engine like crawler, but i'm probably going to use it to hide emails from unregistered users on a forum i moderate

    you'll need more than moderator's permissions to edit the script and hide emails...

     

    but i'm probably going to use it to hide emails from unregistered users on a forum i moderate

    you're probably going to...? seems like a devious plan to me

  14. do a join and then cycle through the results and for each result corresponding to a new ticket echo the new ticket header/text

    i.e.

    $sql = @mysql_query("SELECT t.*, f.name AS filename FROM tickets t JOIN files f ON t.ticket_id = f.ticket_id");
    
    $currentTicket = '';
    
    //table
    echo "<table>";
    
    while ($row = mysql_fetch_array($sql))
    {
    //if not the same ticket as last loop, echo ticket name etc
    if ($currentTicket != $row['ticket_id'])
    {
    echo "<tr><th>{$row['ticket_id']}: {$row['tickettitle']}</th></tr>";
    $currentTicket = $row['ticket_id'];
    }
    
    echo "<tr><td>{$row['filename']}</tr></tr>";
    }
    

  15. you posted those two links wrong, to post urls it is

    [ url=http://www.whatever.com]link text[/url]

    but without the preceding space before url.

     

    as for your problem, i presume the 'long encoded urls' are necessary to point to the correct image - filename, image name etc - this is better for SEO (search engine optimization), another option is to have a database and have images listed by an Image id, so it could be www.yourSite.com/image/3238 with the aid of a .htaccess file, or www.yourSite.com/image/3238.jpg without a .htaccess.

     

    If you don't know how to do either of these I would recommend searching around the web for a gallery which does what you want it to - simpleviewer is a rather simple gallery, all flash based so essentially just one url for all the images. Have a look around, there are plenty of galleries out there

  16. you can't use single quotes inside a string encased in single quote unless you escape the character with a backslash or use double quotes instead. at the start and end of the <img> tag you have single quotes. and also you have a backslash at the end of the tooltip image tag rather than a >

     

    $string = '<a onMouseout="hidetooltip();" onMouseover="tooltip(\"<img src=img/heroes/'.$hero.'.gif>");" href="hero.php?hero='.$hero.'">Text</a>';        echo $string;

     

     

    IMO it would be much easier to write the string in double quotes

     

    $string = "<a onMouseout='hidetooltip();' onMouseover='tooltip(\'<img src=img/heroes/$hero.gif>');' href='hero.php?hero=$hero>Text</a>";        echo $string;

     

     

    have a look at the HTML source of the php page and you could easily rectify this issue.

  17. now since you're using a 2 dimensional array ($array['index']['index2']) your foreach loop is returning $array['index'],

    you are having the index of the 2nd dimensional array as the name of the youtube clip ("rainbow"=>"Double Rainbow Song"), instead you should split that up into 2 index's, such as "clipName" => "Double Rainbow Song", "clip" = > "rainbow", "id"=>"MX0D4oZwCsA" that way you can easily pull array values.

     

    keep the foreach, adjust the arrays as stated above, and then in the foreach you'll be able to pull values like so

                   <?php
                   foreach($youtubeMoreChallenging as $value) {
                   echo '<li>' . str_replace("__YOUTUBE_ID__", $value['id'], $embedCode) . '</li>';
    
    //echo name
    echo $value['clipName'];
    
    //echo clip 
    echo $value['clip'];               
                   
                   
                   } ?> 
    

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