Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Posts posted by joel24

  1. you're not trying to fetch any posted records...

    if(isset($post_items[0])) {
    //should be $_POST['item_name'] since your script will be posting $_POST['item_name'] from your array
    if(isset($_POST['item_name'])) {
    
    //also try this so you get a grasp of what's being posted
    print_r($_POST);
    

  2. the easiest way is to loop through it in a while loop, though you can use mysql_result() to call one row...

     

    //from php.net
    $result = mysql_query('SELECT name FROM work.employee');
    if (!$result) {
        die('Could not query:' . mysql_error());
    }
    echo mysql_result($result, 2); // outputs third employee's name
    
    ## or you could do this instead
    $result = mysql_query('SELECT name, email FROM work.employee');
    if (!$result) {
        die('Could not query:' . mysql_error());
    }
    echo 'name: '.mysql_result($result, 2,'email'); // outputs third employee's email
    echo 'email: '.mysql_result($result, 2,'name'); // outputs third employee's name
    
    

  3. could you use a group by in your sql query to group it by weeks?

    SELECT SUM(cost) 
    FROM table 
    WHERE strtotime BETWEEN $first_date AND $last_date
    GROUP BY WEEK(from_unixtime(strtotime))

     

    otherwise select it all into PHP and use PHP to iterate through each and have an array with totals, and add the cost to the corresponding array index...

    $query="SELECT cost, strtotime FORM table WHERE strtotime BETWEEN $first_date AND $last_date";
    $weeks=array();
    WHILE ($row=mysql_fetch_assoc($query)){
    $currentWeek=date('W',$row['strtotime']);
    $weeks[$currentWeek]+=$row['cost'];
    }
    

     

    have a play around... should help with the groundwork?

  4. if it's working only sometimes, then there must be no blog entries for some... check to see if results returned with mysql_num_rows()

     

                            $query = mysql_query("SELECT content FROM blog WHERE title = '".$title."' ORDER BY date DESC");
    if (mysql_num_rows($query) {
    #now do the fetch
                            while ($row = mysql_fetch_array($query)){
    #etc etc
    } 
    

  5. sorry, my bad

    
    #get unix timecode of dates (seconds past since 1st Jan 1970) - ensure they are either d-m-y or m/d/y
    $start=strtotime($_POST['startDate']);
    $end=strtotime($_POST['endDate']);
    
    #subtract start from end and divide by seconds in day to determine days...
    $days = ($end-$start) / (60*60*24);
    
    echo $days;
    

  6. you're not posting the duration across... you need to add the value to a form element using javascript or you can use PHP to determine the days between...

    You'll need to use a '-' as a seperator rather than '/' - this tells the strtotime() function that it will be a european date format (d-m-y) rather than american (m/d/y)

     

    #get unix timecode of dates (seconds past since 1st Jan 1970) - ensure they are either d-m-y or m/d/y
    $start=strtotime($_POST['startDate']);
    $end=strtotime($_POST['endDate']);
    
    #subtract start from end and divide by seconds in day to determine days...
    $days = $end-$start / (60*60*24);
    
    echo $days;
    

  7. it should be posting the dates to the confirmation.php file... does that file exist and is it located in the same directory? what code is in that file?

    if you want to post the difference you'll have to change

    <li style="list-style: none;" id="duration"></li>
    to
    <input type='text' name='duration' id='duration' />
    

     

    also, you've got a superfluous " at the end of your <form> tag...

    <form name ="drop_list" method = "POST" action ="confirmation.php" ">
    //should be
    <form name ="drop_list" method = "POST" action ="confirmation.php">
    

  8. have a look at this function - just need to modify it to include hours/seconds... and to accept unix timestamps if you're using unix timestamps at all? - from_unixtime()

    http://forums.mysql.com/read.php?10,367815,367819#msg-367819

    CREATE FUNCTION getDateDifferenceString(date1 DATE, date2 DATE) RETURNS VARCHAR(30)
    RETURN CONCAT(
    /* Years between */
    @years := TIMESTAMPDIFF(YEAR, date1, date2),
    IF (@years = 1, ' year, ', ' years, '),
    /* Months between */
    @months := TIMESTAMPDIFF(MONTH, DATE_ADD(date1, INTERVAL @years YEAR), date2),
    IF (@months = 1, ' month, ', ' months, '),
    /* Days between */
    @days := TIMESTAMPDIFF(DAY, DATE_ADD(date1, INTERVAL @years * 12 + @months MONTH), date2),
    IF (@days = 1, ' day', ' days')
    )
    ;
    

  9. use a multi-dimensional array... i.e. $menu[1]['name']='Finance'; $menu[1][x]='Item';

     

    $sql=@mysql_query("SELECT * FROM tableName ORDER BY IFNULL(parent_id,0)");
    
    $menu=array();
    while ($row=mysql_fetch_assoc($sql)) {
    if (is_null($row['parent_id'])) {
    $menu[$row['id']]['name']=$row['menu_name'];
    } else {
    $menu[$row['parent_id'][]=$row['menu_name'];
    }
    
    foreach ($menu AS $m) {
    echo "<ul><li>{$m['name']}";
    
    if (is_array($m) {
    echo "<ul>";
    foreach ($m AS $m2) {
    echo "<li>$m2</li>";
    }
    echo "</ul>";
    }
    echo "</li></ul>";
    }
    

     

    html may be wrong but you get the idea...

  10. if the insert always follows that formatting,

    $ret =  $html->find('table[class=data] tr');
    foreach($ret as $visitor){
    $visitor =  $visitor->find('td','1') . "<br>";
    $replaceArray=array('<td colspan="1" rowspan="1" style="text-align: left;"><a style="border-bottom:1px dotted;" onclick="loadTeamSpotlight(jQuery(this));" rel="HEN" href="javascript:void(0);">','</a></td><br>');
    $visitor=str_replace($replaceArray,'',$visitor);
    $insert="INSERT INTO $dbtable (visitor) VALUES ('$visitor')";
    mysql_query($insert) OR die(mysql_error());
    }
    

     

    ##TEST##
    $string='<td colspan="1" rowspan="1" style="text-align: left;"><a style="border-bottom:1px dotted;" onclick="loadTeamSpotlight(jQuery(this));" rel="HEN" href="javascript:void(0);">HENRY</a></td><br>';
    $replaceArray=array('<td colspan="1" rowspan="1" style="text-align: left;"><a style="border-bottom:1px dotted;" onclick="loadTeamSpotlight(jQuery(this));" rel="HEN" href="javascript:void(0);">','</a></td><br>');
    $string=str_replace($replaceArray,'',$string);
    echo $string;
    

  11. I'm currently writing a Java applet to access and scan wifi networks and I need to execute the netsh with the parameters "wlan show networks mode=bssid".

     

    The script is being run from a HTML page and so the Applet is limited to the sandbox environment. What would be the best way to grant permissions to execute said command?

     

    At the moment I'm getting warnings when compiling the class, sorry this is my first Java applet - feel free to point me toward any relevant tutorials?

    warning: [unchecked] unchecked con

    version

                            AccessController.doPrivileged(new PrivilegedAction() {

                                                          ^

      required: PrivilegedAction<T>

      found:    <anonymous PrivilegedAction>

      where T is a type-variable:

        T extends Object declared in method <T>doPrivileged(PrivilegedAction<T>)

    c:\users\joel\desktop\javaTest\wifox.java:28: warning: [unchecked] unchecked met

    hod invocation: method doPrivileged in class AccessController is applied to give

    n types

                            AccessController.doPrivileged(new PrivilegedAction() {

                                                        ^

      required: PrivilegedAction<T>

      found: <anonymous PrivilegedAction>

      where T is a type-variable:

        T extends Object declared in method <T>doPrivileged(PrivilegedAction<T>)

    2 warnings

     

    and the current code

    public static void testing() {
    		AccessController.doPrivileged(new PrivilegedAction() {
    		public Object run() {
    			try {
    				// Run "netsh" Windows command
    				Process process = Runtime.getRuntime().exec("netsh.exe wlan show networks mode=bssid");
    
    				// Get input streams
    				BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
    				BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));
    
    				// Read command standard output
    				String s;
    				System.out.println("Networks Found: ");
    				while ((s = stdInput.readLine()) != null) {
    					System.out.println(s);
    				}
    
    				// Read command errors
    				System.out.println("Errors: ");
    				while ((s = stdError.readLine()) != null) {
    					System.out.println(s);
    				}
    			} catch (Exception e) {
    				e.printStackTrace(System.err);
    			}
    		}
    	});
    }
    

  12. working fine in IE8 for me,

    test.css

    .txt {
    color: #f0f;
    }
    

     

    test.htm

    <html>
    
    <head>
    <link rel="stylesheet" type="text/css" href="test.css" />
    </head>
    
    <body>
    test
        <form>
        <span class="txt">
        Name
        <input />
        </span>
        </form>
    </body>
    
    </html>
    

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