Jump to content

harristweed

Members
  • Posts

    346
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by harristweed

  1. <?php
    $directory="..\yourdirectory";
    $dir="$directory";
    $dp=opendir($dir);
      while($file = readdir($dp)){
          if($file != '.' && $file != '..' ){
    $insert=" insert into table ( file_name_table ) values ( '$file')";     
    mysql_query($insert,$link_id);
              }
          }
    ?>

  2. this is a bit 'cor blimmey' but a simple way is with a flag.

    $errors=0;
    
    // add flag to all error checks
    if (!$_POST["user"] | !$_POST["pass"] | !$_POST["email"] ) { 
          echo "<div class='error'>Please fill in the required fields</div>";
    $errors=1;
                    }
    
    // then test the flag before putting data into database
    
    if ($flag < 1){
    // add data
    }else{
    //show error message
    }
    

     

  3. I don't believe this worked on any server!

    #selects all data from table and displays it in textfields. If failed, it will display the error
    		$sql = "SELECT * from tblquotes ORDER BY Rand() LIMIT 1";

    Does not select all data, it is LIMITED to one row!

    And

    $result = mysql_query($sql,$connection);
    
    		if($result = mysql_query($sql ,$connection)) {

    runs twice $result = mysql_query($sql,$connection); and I suspect this will move the record pointer on so that the one row you have retrieved is not displayed.

  4. of course it does! doh!

      <?php
    
    $rss_file = "http://www.uefa.com/rssfeed/news/rss.xml";
    $rss_feed = simplexml_load_file( $rss_file );
    $count=1;
    
    foreach( $rss_feed->channel->item as $item  ) {
    echo"<a title='$item->title' href='$item->link'> $item->title</a>";
    $count++;
    if($count >10)continue;
    }
    ?>
    

  5.   <?php
    
    $rss_file = "http://www.uefa.com/rssfeed/news/rss.xml";
    $rss_feed = simplexml_load_file( $rss_file );
    $count=0;
    
    foreach( $rss_feed->channel->item as $item  ) {
    while($count<10){
    echo"<a title='$item->title' href='$item->link'> $item->title</a>";
    $count++;
    }
    }
    ?>

  6. If the page is refreshed then the data will update again. Therefore I suggest have the form access a script, the update script is held in a separate file, after a successful update redirect back to the form then refresh of the form will refresh that page and not the update script!

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