Results 1 to 9 of 9

Thread: Need help with script

  1. #1

    Thread Starter
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372

    Need help with script

    Hi,

    I need help with this php script. The bit of code below is to show a list of shows and their dates. It shows the From and To dates but a lot of the shows are only on for one night so they show, for example: Sat 05 Oct - Sat 05 Oct.
    How can I change it so that if a show is only on one night it will only show the one date, eg. Sat 05 Oct.

    PHP Code:
    function list_all_movies() // show all movies
    {
    // query
    $query="SELECT id, title, qft1_date_from, qft1_date_from_timestamp, qft1_date_to, qft1_date_to_timestamp FROM movies ORDER BY id"// find all bad words

    database_connect();        //connect to the database

    $result=mysql_query($query);      // Executes the query
    $rows_number=mysql_num_rows($result); //count the number of rows/bad words

    echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\">";


    for (
    $i=0$i<$rows_number$i++) // get info from evry record and display it into the table

        
    $row_array=mysql_fetch_row($result); // Fetching the array

        
    $id=$row_array[0];
        
    $title=$row_array[1];
        
    $qft1_date_from=$row_array[2];
        
    $qft1_date_from_timestamp=$row_array[3];
        
    $qft1_date_to=$row_array[4]; // we use $package_type_ but not $package_type because of global variables problem.
        
    $qft1_date_to_timestamp=$row_array[5];

        
    // visualization conversion
        
    $visualize_qft1_from=date("D d-M",$qft1_date_from_timestamp); 
        
    $visualize_qft1_to=date("D d-M",$qft1_date_to_timestamp); 

        
    //adjustig the hours visualization
        
    $qft1_hours="<font size=\"-1\"> $visualize_qft1_from - $visualize_qft1_to; </font>";
        if (
    $qft1_date_from== "0000-00-00" or $qft1_date_to== "0000-00-00") {$qft1_hours="";}


        echo
        
    "
         <tr>
                <td width=\"400\">
                    <p><font size=\"-1\"><a href=\"description.php?id=
    $id\">$title</a></font></p>
                </td>
                <td width=\"542\">
                    <p><a href=\"description.php?id=
    $id\">$qft1_hours</a></p>
                </td>
            </tr>
        "
    ;
    // end of for

    echo "</table>";

    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

  2. #2

    Thread Starter
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372
    Can anyone help? I need to have it fixed by Monday.
    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Give this a shot:

    Code:
    function list_all_movies() // show all movies
    {
    // query
    $query="SELECT id, title, qft1_date_from, qft1_date_from_timestamp, qft1_date_to, qft1_date_to_timestamp FROM movies ORDER BY id"; // find all bad words
    
    database_connect();        //connect to the database
    
    $result=mysql_query($query);      // Executes the query
    $rows_number=mysql_num_rows($result); //count the number of rows/bad words
    
    echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\">";
    
    
    for ($i=0; $i<$rows_number; $i++) // get info from evry record and display it into the table
    { 
        $row_array=mysql_fetch_row($result); // Fetching the array
    
        $id=$row_array[0];
        $title=$row_array[1];
        $qft1_date_from=$row_array[2];
        $qft1_date_from_timestamp=$row_array[3];
        $qft1_date_to=$row_array[4]; // we use $package_type_ but not $package_type because of global variables problem.
        $qft1_date_to_timestamp=$row_array[5];
    
        // visualization conversion
        $visualize_qft1_from=date("D d-M",$qft1_date_from_timestamp); 
        $visualize_qft1_to=date("D d-M",$qft1_date_to_timestamp); 
    
        //adjustig the hours visualization
        
        if ($visualize_qft1_from == $visualize_qft1_to) {
            $qft1_hours="<font size=\"-1\">$visualize_qft1_from</font>";
        } else {
            $qft1_hours="<font size=\"-1\"> $visualize_qft1_from - $visualize_qft1_to; </font>";
        }
        
        if ($qft1_date_from== "0000-00-00" or $qft1_date_to== "0000-00-00") {$qft1_hours="";}
    
    
        echo
        "
         <tr>
                <td width=\"400\">
                    <p><font size=\"-1\"><a href=\"description.php?id=$id\">$title</a></font></p>
                </td>
                <td width=\"542\">
                    <p><a href=\"description.php?id=$id\">$qft1_hours</a></p>
                </td>
            </tr>
        ";
    } // end of for
    
    echo "</table>";
    }
    New code is in bold. Let me know if that works.
    Last edited by The Hobo; Oct 4th, 2002 at 03:42 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4

    Thread Starter
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372
    Thanks, I'll try it now.
    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

  5. #5

    Thread Starter
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372
    Thanks Hobo, it worked.
    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

  6. #6
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Best of luck.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7

    Thread Starter
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372
    hi again,

    I need to do the same thing with this script:

    PHP Code:
    <?php 
    if ($qft1_date_from<>"0000-00-00" and $qft1_date_to<>"0000-00-00")
         {
         
    $visualize_qft1_from=date("D d-M",$qft1_date_from_timestamp); 
         
    $visualize_qft1_to=date("D d-M",$qft1_date_to_timestamp); 
         echo 
    "From $visualize_qft1_from to $visualize_qft1_to";
         }
    ?>
    I tried doing it myself but made a right mess of it. I'm not good with php.
    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

  8. #8
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Code:
    <?php 
    if ($qft1_date_from<>"0000-00-00" and $qft1_date_to<>"0000-00-00")
         {
         $visualize_qft1_from=date("D d-M",$qft1_date_from_timestamp); 
         $visualize_qft1_to=date("D d-M",$qft1_date_to_timestamp); 
         if ($visualize_qft1_from == $visualize_qft1_to) {
             echo "On $visualize_qft1_from";
         } else {
             echo "From $visualize_qft1_from to $visualize_qft1_to";
         }
    }
    ?>
    My evil laugh has a squeak in it.

    kristopherwilson.com

  9. #9

    Thread Starter
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372
    That's great. Thanks.
    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width