Current location: Hot Scripts Forums » Programming Languages » PHP » PHP help needed by newbie


PHP help needed by newbie

Reply
  #1 (permalink)  
Old 05-23-05, 08:02 AM
pixelluxe pixelluxe is offline
Newbie Coder
 
Join Date: May 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
PHP help needed by newbie

Hey guys. I implemented my first php script last night, and I have all but one thing working. I used this script:

Code:
http://www.hotscripts.com/Detailed/22477.html
And I implemented it here:

Code:
http://www.shakedownmusic.net/test6.php
I made several modifications to make the script fit into the layout I'm using for the website, but I can't figure out how to modify one thing... If you look at the "Upcoming Shows" area, you will see that the date prints as the number of the month with no leading zeros. I'd like that to print as the full textual version of the month (ie 1 should equal January and so on). I looked in some books and tried using if statements to say if the_month = 1 then the_full_month = January, but I don't know the correct syntax or if that's the best way to do it.

Any help you guys could give me would be greatly appreciated. Thanks for your time!

Marcus

Here is the script after my mods:
PHP Code:

<?php

    
// read in the connection settings
    
require("showlist/samples/showlister_settings.inc.php");
    require(
"showlist/samples/showlister_methods.inc.php");

    
// connect to the RDBMS
    
$db mysql_connect("$site","$user","$pass"
        or 
die_now("<h2>Could not connect to database server</h2><p>Check passwords and sockets</p>");

    
// select the database
    
mysql_select_db("$database",$db
        or 
die_now("<h2>Could not select database $database</h2><p>Check database name</p>");

    
// select all the shows in the database
    
$result mysql_query("select show_id, month, day, year, location, details, venue
        from 
$database_table order by year, month, day",$db
        or 
die_now("<h2>Could not select shows</h2>");

    
// set up the table        
    
echo("<div id='shows' style='position:absolute; left:6px; top:193px; width:265px; height:189px; z-index:6; overflow: auto;'>\n");
    echo(
"<table width='239' border='0' cellspacing='0' cellpadding='0'>\n");
    echo(
"\t<tr>\n\t\t<td colspan='3'><img src='images/blank_line.gif'></td>\n\t\t</tr>\n");

    
// print the next five shows
    // thanks to Lee Mikles (lee@getcohesive.com) for contributing the
    // first version of this code
      
$cur_month date("n");
      
$cur_day date("d");
      
$cur_year date("Y");
      
$event_count=1;

  
// echo out the next five shows
    
while(($row mysql_fetch_array($result)) and ($event_count <= 10)) {
      
$the_id $row["show_id"];
      
$the_month $row["month"];
      
$the_day $row["day"];
      
$the_year $row["year"];
      
$the_location $row["location"];
      
$the_details $row["details"];
      
$the_venue $row["venue"];

      if ((
$the_year $cur_year)) {
        
// echo shows in future years
        
echo("\t<tr>\n");
        echo(
"\t\t<td width='3'><img src='images/3x3spacer.gif'></td>\n");
        echo(
"\t\t<td class='title1' width='233' bgcolor='#000000'>&nbsp; $the_month" " "$the_day", " "$the_year"</td>\n");
        echo(
"\t\t<td width='3'><img src='images/3x3spacer.gif'></td>\n");
        echo(
"\t</tr>\n");
        echo(
"\t<tr>\n");
        echo(
"\t\t<td><img src='images/3x3spacer.gif'></td>\n");
        echo(
"\t\t<td class='title2' bgcolor='#4F3500'>&nbsp; $the_venue" -- " "$the_location</td>\n");
        echo(
"\t</tr>\n");
        echo(
"\t<tr>\n");
        echo(
"\t\t<td colspan='3'><img src='images/dotted_line.gif' width='239' height='6'></td>\n");
        
$event_count++;
      }
      
      if ((
$the_month $cur_month) and ($the_year $cur_year)) 
      {
        
// echo shows in future months of current year
        
echo("\t<tr>\n");
        echo(
"\t\t<td width='3'><img src='images/3x3spacer.gif'></td>\n");
        echo(
"\t\t<td class='title1' width='233' bgcolor='#000000'>&nbsp; $the_long_month" " "$the_day", " "$the_year"</td>\n");
        echo(
"\t\t<td width='3'><img src='images/3x3spacer.gif'></td>\n");
        echo(
"\t</tr>\n");
        echo(
"\t<tr>\n");
        echo(
"\t\t<td><img src='images/3x3spacer.gif'></td>\n");
        echo(
"\t\t<td class='title2' bgcolor='#4F3500'>&nbsp; $the_venue" -- " "$the_location</td>\n");
        echo(
"\t</tr>\n");
        echo(
"\t<tr>\n");
        echo(
"\t\t<td colspan='3'><img src='images/dotted_line.gif' width='239' height='6'></td>\n");
        
$event_count++;
      }
      
      if ((
$the_month $cur_month) and ($the_day >= $cur_day) and ($the_year $cur_year)) 
      {
        
// echo shows in current month, today and later
        
echo("\t<tr>\n");
        echo(
"\t\t<td width='3'><img src='images/3x3spacer.gif'></td>\n");
        echo(
"\t\t<td class='title1' width='233' bgcolor='#000000'>&nbsp; $the_month" " "$the_day", " "$the_year"</td>\n");
        echo(
"\t\t<td width='3'><img src='images/3x3spacer.gif'></td>\n");
        echo(
"\t</tr>\n");
        echo(
"\t<tr>\n");
        echo(
"\t\t<td><img src='images/3x3spacer.gif'></td>\n");
        echo(
"\t\t<td class='title2' bgcolor='#4F3500'>&nbsp; $the_venue" -- " "$the_location</td>\n");
        echo(
"\t</tr>\n");
        echo(
"\t<tr>\n");
        echo(
"\t\t<td colspan='3'><img src='images/dotted_line.gif' width='239' height='6'></td>\n");
        
$event_count++;
      }
      }
    
// close the table
    
echo("\t</tr>\n\t<tr>\n\t\t<td colspan='3'><img src='images/blank_line.gif' width='239' height='6'></td>\n\t</tr></table>\n</div>\n");
?>
Reply With Quote
  #2 (permalink)  
Old 05-23-05, 08:49 AM
pixelluxe pixelluxe is offline
Newbie Coder
 
Join Date: May 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Never Mind!

Never mind guys, I figured it out. I used this syntax and it worked.

PHP Code:

      if ($the_month == '1')

         {
$the_long_month "January";}
      if (
$the_month == '2')
         {
$the_long_month "February";}
      if (
$the_month == '3')
         {
$the_long_month "March";}
      if (
$the_month == '4')
         {
$the_long_month "April";}
      if (
$the_month == '5')
         {
$the_long_month "May";}
      if (
$the_month == '6')
         {
$the_long_month "June";}
      if (
$the_month == '7')
         {
$the_long_month "July";}
      if (
$the_month == '8')
         {
$the_long_month "August";}
      if (
$the_month == '9')
         {
$the_long_month "September";}
      if (
$the_month == '10')
         {
$the_long_month "October";}
      if (
$the_month == '11')
         {
$the_long_month "November";}
      if (
$the_month == '12')
         {
$the_long_month "December";} 
Reply With Quote
  #3 (permalink)  
Old 05-23-05, 10:13 AM
hermawan hermawan is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Did you know anything about "date" function in PHP?
Check this out: http://codewalkers.com/tutorials/29/1.html
__________________
Hermawan Haryanto
Senior Programmer - Red Rock Reef LLC
Las Vegas, Nevada 89123 USA
1.800.9.Subnet | Fax: 1.702.920.8277
http://www.redrockreef.com
Reply With Quote
  #4 (permalink)  
Old 05-23-05, 10:15 AM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
The best tutorial: Detailed Date syntax etc from the OFFICIAL source.
http://www.php.net/date
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
  #5 (permalink)  
Old 05-24-05, 07:07 PM
pixelluxe pixelluxe is offline
Newbie Coder
 
Join Date: May 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for your help guys. I learned a lot by looking at php.net
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Developer Needed for Open Source (LGPL) Project Olate Job Offers & Assistance 2 08-24-10 08:02 AM
PHP programmer needed! $$$ lylesback2 Job Offers & Assistance 2 06-13-05 09:19 PM
PHP Programer(s) needed to work on open source project with me blasto333 Job Offers & Assistance 0 11-19-04 06:55 PM
PHP and CSS Expert NEEDED!!!! eFutureMedia Job Offers & Assistance 1 09-11-04 01:53 PM
PHP and CSS Expert NEEDED!!!! eFutureMedia PHP 4 09-11-04 08:34 AM


All times are GMT -5. The time now is 06:45 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.