Jump to content

AndyB

Staff Alumni
  • Posts

    5,465
  • Joined

  • Last visited

    Never

Posts posted by AndyB

  1. Any way I could send you the file I have through email?

    No thanks.

     

    The way we all learn is by sharing knowledge. If you want to post some information about your database structure, and some information about what you want in the .csv file that will result from querying it and creating a text file, then everyone here can contribute to the solution you're working towards, and anyone who reads the thread (now or in future) will see how a particular problem was solved.

     

    That's what these forums are all about: shared problems, shared solutions.

  2. If you want to USE MySQL on your local computer, you really don't have any option but to install it - along with something that'll let you use your local computer as a server.

     

    If you want to run php and MySQL and the GD library on your computer as if it were a server, then there's an 11.5 MB downloadable at www.firepages.com.au as a single package with a one-click installation. phpdev423 is perfect for all local development. I've installed it on Win NT, Win2K, and WinXP all without any problems whatsoever.

  3. As far as I know, you can't create a true .xls file using php/MySQL. What you CAN do is generate a text file from the MySQL data. And then you can IMPORT that text file into Excel.

     

    Assuming you know how to get the data you want out of your database, you'll find all you need to know about creating a text file in the manual - check fwrite for that.

  4. Cautionary note: I am entering dates in the .... format. But what about every other user of the form? I'd suggest user-proofing the data entry by having three date entry fields - day, month, year (dropdowns are nice and user-proof). Then it doesn't matter what date format the user thinks of using, since your form will always have the responses in the same format.

  5. The phpinfo script from your domain clearly shows register_globals is set to ON, so you should be able to read passed variables 'directly'. Can you post a small sample of code that works locally and doesn't work on your domain server, so we can take a closer look just in case there's something weird there?

  6. [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php

    [/span][span style=\"color:#007700\"]echo [/span][span style=\"color:#DD0000\"]\"And no more script error message.\"[/span][span style=\"color:#007700\"];

    [/span][span style=\"color:#0000BB\"]?>[/span]

    [/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

  7. Can someone tell Dummy here why the script below won't work??

    I doubt it, because it's just about unreadable and nobody's going to take the time to figure out where one line ends and the next begins.

     

    It would help if you edited your post so that each line of your code was on a separate line, and you wrapped the code with the 'CODE' tags available here.

  8. Here's the one I use. You can format the output as you see fit. And it only shows events that haven't passed. Database table construction should be evident from the code below (I hope).

     

    <?
    include("local_includes/top.php");
    
    echo "<h1>Events Calendar</h1>";
    
    // show what's new as a separate page - all data
    $nodat = "<p>The \"<em>events</em>\" database is currently empty.</p>";
    include("local_includes/db_conn.php");
    $dbtable = "happening";
    $today = date("Y-m-d");
    
    mysql_connect($dbhost, $dblogin, $dbpass) or die ("Error: Unable to connect to the database."); 
    mysql_select_db($dbname) or die ("Error: Unable to open the database."); 
    $query = "SELECT * FROM $dbtable where ev_dat>'$today' order by ev_dat"; 
    $result = mysql_query ($query);
    $recs = mysql_num_rows($result); // any information in database?
    if(!$recs) {
       echo $nodat;
    }
    else {
       while ($myrow = mysql_fetch_array($result)) // loop through all results
       { 
           echo "<h2>";
     $new_dt = strtotime($myrow['ev_dat']);
     echo date("l, F j, Y" , $new_dt);
     echo "</h2><p>";
           echo "Event: ". $myrow['ev_title']. "<br />Location: ". $myrow['ev_locn'];
     if ($myrow['ev_desc']!="") {
         echo "<br />Details: ". nl2br($myrow['ev_desc']);
     }	
     echo "</p><br />";
       }
    }
    
    include("local_includes/bottom.php");
    ?>

    Database table:

    CREATE TABLE happening (

      id smallint(4) NOT NULL auto_increment,

      ev_dat date NOT NULL default '0000-00-00',

      ev_locn varchar(60) NOT NULL default '',

      ev_title text NOT NULL,

      ev_desc text,

      PRIMARY KEY  (id)

    ) TYPE=MyISAM;

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