www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Simple PHP question about variables

  1. #1
    Join Date
    Jun 2012
    Location
    FL, USA
    Posts
    48

    resolved [RESOLVED] Simple PHP question about variables

    if I have, for example

    $timein1 = 'something';

    $timeout3 = 'something else';

    $inorout = 'in';
    $n = '1';

    can I use

    print ${time.$inorout.$n} to get the result 'something'...?

    It isn't working..

  2. #2
    Join Date
    Jun 2012
    Location
    FL, USA
    Posts
    48
    ok, I just tested that reality. apparently it works but my real code isn't doing what i want. Here goes:

    Code:
    function makeSelect($inorout, $x)
    {
    if ($inorout == "in")
    	{$output = "<select name='timein$x' id='timein$x'>";}
    elseif ($inorout == "out")
    	{$output = "<select name='timeout$x' id='timeout$x'>";}
    
    if (${time.$inorout.$x} == '') {$output .= "<option value='' selected='selected'></option>";}
    else {$output .= "<option value=''></option>";}	
    
    
    			for ($h = 6; $h <= 22; $h++)
    			{
    				if (${time.$inorout.$x} == '$h:00') {$output .= "<option value='$h:00' selected='selected'>$h:00</option>";}
    				else { $output .= "<option value='$h:00'>$h:00</option>"; }
    
    				if (${time.$inorout.$x} == '$h:15') {$output .= "<option value='$h:15' selected='selected'>$h:15</option>";}
    				else { $output .= "<option value='$h:15'>$h:15</option>"; }
    
    				if (${time.$inorout.$x} == '$h:30') {$output .= "<option value='$h:30' selected='selected'>$h:30</option>";}
    				else { $output .= "<option value='$h:30'>$h:30</option>"; }
    
    				if (${time.$inorout.$x} == '$h:45') {$output .= "<option value='$h:45' selected='selected'>$h:45</option>";}
    				else { $output .= "<option value='$h:45'>$h:45</option>"; }
    
    
    			}
    			if (${time.$inorout.$x} == '23:00') {$output .= "<option value='23:00' selected='selected'>23:00</option>";}
    			else {$output .= "<option value='23:00'>23:00</option>"; }
    
    			if (${time.$inorout.$x} == '23:15') {$output .= "<option value='23:15' selected='selected'>23:15</option>";}
    			else {$output .= "<option value='23:15'>23:15</option>"; }
    
    			if (${time.$inorout.$x} == '23:30') {$output .= "<option value='23:30' selected='selected'>23:30</option>";}
    			else {$output .= "<option value='23:30'>23:30</option>"; }
    			
    $output .= "</select>";
    
    echo $output;
    }

  3. #3
    Join Date
    Jun 2012
    Location
    FL, USA
    Posts
    48
    I posted another thread revising this question and for some reason I can't delete it so I'm marking it resolved

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles