|
-
Oct 4th, 2002, 07:18 AM
#1
Thread Starter
Hyperactive Member
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>";
}
-
Oct 4th, 2002, 03:32 PM
#2
Thread Starter
Hyperactive Member
Can anyone help? I need to have it fixed by Monday.
-
Oct 4th, 2002, 03:39 PM
#3
Stuck in the 80s
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.
-
Oct 4th, 2002, 03:52 PM
#4
Thread Starter
Hyperactive Member
-
Oct 4th, 2002, 04:04 PM
#5
Thread Starter
Hyperactive Member
Thanks Hobo, it worked.
-
Oct 4th, 2002, 04:40 PM
#6
Stuck in the 80s
Best of luck.
-
Oct 8th, 2002, 09:39 AM
#7
Thread Starter
Hyperactive Member
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.
-
Oct 8th, 2002, 10:16 AM
#8
Stuck in the 80s
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";
}
}
?>
-
Oct 8th, 2002, 10:31 AM
#9
Thread Starter
Hyperactive Member
That's great. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|