Jump to content

harristweed

Members
  • Posts

    346
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by harristweed

  1. Post can only be sent from forms. The easiest way to get your pagination working is to append the username to the url.

     

    Change the form to GET and add the username to the page links...

    <form action='search.php?find' method='get'> 

     

    then

    echo "<a href='{$_SERVER['PHP_SELF']}?start=$prev&username=$_GET['username']'>Prev</a> ";

    etc.

  2. $db = mysql_connect("localhost", "MYUSERNAME", "MYPASSWORD");
    mysql_select_db("MYDATABASE",$db);
    
    $query="SELECT * FROM MYTABLENAME";
    $result=mysql_query($query);
    
    $header="firstname\t lastname\t emailaddress\t crew_name_001\t ";
    while($row = mysql_fetch_assoc($result)) {
        if(empty($row[firstname]))$row[firstname]=" ";
        if(empty($row[lastname]))$row[lastname]=" ";
        if(empty($row[emailaddress]))$row[emailaddress]=" ";
        if(empty($row[crew_name_001]))$row[crew_name_001]=" ";
        $line = ''; 
        $line .= "$row[firstname]\t $row[lastname]\t $row[emailaddress]\t $row[crew_name_001]\t "; 
        $data .= trim($line)."\n"; 
    } 
    $data = str_replace("\r","",$data); 
    if ($data == "") { 
        $data = "\n(0) Records Found!\n";                         
    } 
    
    header("Content-type: application/x-msdownload"); 
    header("Content-Disposition: attachment; filename=filename=".date("d-m-Y")."-export.xls"); 
    header("Pragma: no-cache"); 
    header("Expires: 0"); 
    print "$header\n$data";
    exit;

     

  3. I have found attachments a bit of a nightmare! Why not email a link?

    $header="column name\t column name\t column name\t column name\t column name\t";
    $select="select * from table_name where condition ";                
    $export = mysql_query($select);
    while($row = mysql_fetch_assoc($export)) {
        if(empty($row[a]))$row[a]=" ";
        if(empty($row[b]))$row[b]=" ";
        if(empty($row[c]))$row[c]=" ";
        if(empty($d[d]))$row[d]=" ";
        $line = ''; 
        $line .= "$row[first_name]\t $row[surname]\t $row[email]\t $row[phone]\t $lang[$key]\t"; 
        $data .= trim($line)."\n"; 
    } 
    $data = str_replace("\r","",$data); 
    if ($data == "") { 
        $data = "\n(0) Records Found!\n";                         
    } 
    header("Content-type: application/x-msdownload"); 
    header("Content-Disposition: attachment; filename=$file_name"); 
    header("Pragma: no-cache"); 
    header("Expires: 0"); 
    print "$header\n$data";

  4. <?php
      $the_array=array("1","2","3","4","5","6");
      
      $x=3;
      
      $first_part=array();
      $second_part=array();
      foreach ($the_array as $value) {
      if($value <= $x){
          $second_part[]=$value;
      }else{
          $first_part[]=$value;
      }
      $sorted_array=array_merge($first_part, $second_part);
      }
    
      foreach ($sorted_array as $value) {
      echo"$value<br />\n";
      }
    ?>

  5. goto less; Will give an error, so will less:

     

    You were also missing some braces

     

    <?php
    
    for ($count = 0; $count < 10; $count++)
    {
    $randomNumber = rand(1,50);
    if ($randomNumber < 10){
    //goto less;
    }else{
    echo "Number greater than 10: $randomNumber<br />";
    }
    //less:
    echo "Number less than 10: $randomNumber<br />";
    }
    ?>

  6.   //SQL Query of Questions
    $image_displayed=0;
         //For Loop
         {
           //   Output Data
            //  SQL Query Of Possible Answers
    if($image_displayed==0){
              [i]Output answer image here[/i]
    $image_display++;
    }
                   For Loop
                   {
                        Output Data
                   }
           }

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