Arrays, text areas and concatenation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Flashart
Forum Commoner
Posts: 71
Joined: Tue Oct 06, 2009 12:12 pm

Re: Arrays, text areas and concatenation

Post by Flashart »

All sorted now thanks!

Now to complicate things more, I am looking at expanding the number of multipliers, so there will be multiplier_box_2 etc. I will have a stab at just using the code we have, but I know where to come if I get stuck!

Thanks for your help! :D
curlybracket
Forum Commoner
Posts: 59
Joined: Mon Nov 29, 2010 2:40 pm

Re: Arrays, text areas and concatenation

Post by curlybracket »

Good luck :)
Flashart
Forum Commoner
Posts: 71
Joined: Tue Oct 06, 2009 12:12 pm

Re: Arrays, text areas and concatenation

Post by Flashart »

OK I had a stab and no luck!

Damn this is proving to be quite complicated!

Essentially I just added a further if statement to the code for the multiplier 2 box, thinking it will be fine but no..!

Code: Select all

<?php
ini_set('display_errors', true);    // display errors in the browser
error_reporting (E_ALL ^ E_NOTICE);
include ("config.php");
if(isset($_POST)) 

{
    $firstTextarea = $_POST['textarea'];
    $secondTextarea = $_POST['multiplier_textarea'];
    $thirdTextarea = $_POST['multiplier_textarea_2'];
    $firstArray = explode("\n", $firstTextarea);
    $secondArray = explode("\n", $secondTextarea);
    $thirdArray = explode("\n", $thirdTextArea);
  


  }
?>
<!DOCTYPE html>

<body>
<div id="container">

<div id="form_container">
<form action="" method="post">
 	<input type="submit" name="broad" class="match_button"
        value="Broad"/>
        <input type="submit" name="phrase" class="match_button" value=""Phrase""/>
        <input type="submit" name="exact" class="match_button" value="[Exact]"/>
        <input type="submit" name="broad_phrase" class="match_button" value="Broad & "Phrase"" />
        <input type="submit" name="broad_exact" class="match_button" value="Broad & [Exact]" />
        <input type="submit" name="broad_phrase_exact" class="match_button" value="Broad & "Phrase&quot & [Exact]" />
         <input type="submit" name="phrase_exact" class="match_button" value=""Phrase&quot & [Exact]" />
   	<!--	<input type="reset" value="Reset" class="match_button" />    -->

   <textarea name="textarea" id="textarea">Keyword area</textarea>

<textarea name="multiplier_textarea" id="multiplier_textarea">Multiplier area 1</textarea>
<textarea name="multiplier_textarea_2" id="multiplier_textarea_2">Multiplier area 2</textarea>
<textarea name="multiplier_textarea_3" id="multiplier_textarea_3">Multiplier area 3</textarea>
  



</form>
</div>

<div id="results">
 <?php
    
 foreach($firstArray as $key => $value)
    {
    	  foreach($secondArray as $key2 => $value2)
    	  	{
    	  		
    	  		foreach($thirdArray as $key3 => $value3)
    	  			{
    	  
    	  		//Broad code
    	  		if(isset($_POST['broad']))
    	  		
    				if(!empty($value2))			            
            	        {
                                echo ''.$value.' '.$value2. ' '.$value3.'<br/>';
                        }
                        else
                        {
                                echo ''.$value.'<br/>';
                        }
                  
                //Phrase Code      
               	if(isset($_POST['phrase']))
    				
    				if(!empty($value2))					            
            	        {
                                echo '"'.$value.' '.$value2.'"<br/>';
                        }
                        else
                        {
                                echo '"'.$value.'"<br/>';
                        }
                        
                //Exact code
    			if(isset($_POST['exact']))
    				
    				if(!empty($value2))					            
            	        {
                                echo '['.$value.' '.$value2.']<br/>';
                        }
                        else
                        {
                                echo '['.$value.']<br/>';
                        }
                        
                 
                 // Broad & Phrase code     
                 if(isset($_POST['broad_phrase']))
    				
    				if(!empty($value2))
					    {
                                echo ''.$value.' '.$value2.'<br/>';
                                echo '"'.$value.' '.$value2.'"<br/>';
                        }
                        else
                        {
                                echo ''.$value.'<br/>';
								echo '"'.$value.'"<br/>';                        }
								
				 //Broad & Exact code
				 if(isset($_POST['broad_exact']))
    				
    				if(!empty($value2))					            
            	        {
                                echo ''.$value.' '.$value2.'<br/>';
                                echo '['.$value.' '.$value2.']<br/>';
                        }
                        else
                        {
                                echo ''.$value.'<br/>';
								echo '['.$value.']<br/>';                        }
								
				//Broad, Phrase & Exact code				
				 if(isset($_POST['broad_phrase_exact']))
    				
    				if(!empty($value2))
            	        {
                                echo ''.$value.' '.$value2.'<br/>';
                                echo '"'.$value.' '.$value2.'"<br/>';
                                echo '['.$value.' '.$value2.']<br/>';
                        }
                        else
                        {
                                echo ''.$value.'<br/>';
								echo '"'.$value.'"<br/>'; 
                                echo '['.$value.']<br/>';
						}
						
										
				//Phrase & Exact code				
				 if(isset($_POST['phrase_exact']))
    				
    				if(!empty($value2))
            	        {
                                echo '"'.$value.' '.$value2.'"<br/>';
                                echo '['.$value.' '.$value2.']<br/>';
                        }
                        else
                        {
								echo '"'.$value.'"<br/>'; 
								echo '['.$value.' '.$value2.']<br/>';
						}
						
						//third textare ending bracket
						}
				
            //penultimate ending curly bracket
                       }
        // ending curly bracket
        }
 
       ?>
        </div>
        	</div>
        </body>
        </html>
I'm guessing the syntax needs to be re-arranged but I'm not sure how? Any help would be most gratefully received.

Kind regards
Peter
curlybracket
Forum Commoner
Posts: 59
Joined: Mon Nov 29, 2010 2:40 pm

Re: Arrays, text areas and concatenation

Post by curlybracket »

Your code doesn't work because you ignored case of the letters, look:

Code: Select all

$firstTextarea = $_POST['textarea'];
$secondTextarea = $_POST['multiplier_textarea'];
$thirdTextarea = $_POST['multiplier_textarea_2'];   // new var $thirdTextarea
$firstArray = explode("\n", $firstTextarea);
$secondArray = explode("\n", $secondTextarea);
$thirdArray = explode("\n", $thirdTextArea);  // $thirdTextArea is not the same as $thirdTextarea
so change this line:

Code: Select all

$thirdArray = explode("\n", $thirdTextArea); 
to

Code: Select all

$thirdArray = explode("\n", $thirdTextarea); 
and you will get one step further :)
Flashart
Forum Commoner
Posts: 71
Joined: Tue Oct 06, 2009 12:12 pm

Re: Arrays, text areas and concatenation

Post by Flashart »

I don't believe it!

You wouldn't believe how long I studied the code! Couldn't see the wood for the trees!

Thanks! :D
curlybracket
Forum Commoner
Posts: 59
Joined: Mon Nov 29, 2010 2:40 pm

Re: Arrays, text areas and concatenation

Post by curlybracket »

It wasn't very difficult to solve, the best thing you can do is to ask yourself why couldn't you find this by yourself. I was testing the code like this:
First thing I did was to find out that $value3 has to be empty in this line:

Code: Select all

echo ''.$value.' '.$value2. ' '.$value3.'<br/>';
because text from multiplier_textarea_2 wasn't displayed.
So I printed out $third array:

Code: Select all

foreach($secondArray as $key2 => $value2)
{
  print_r($thirdArray);
  foreach($thirdArray as $key3 => $value3)
  {
only to find out that it is empty. Then I printed out $thirdArray earlier in the code:

Code: Select all

$thirdArray = explode("\n", $thirdTextArea);
print_r($thirdArray); 
and saw that it is still empty. So I printed out $thirdTextArea and saw that it is empty too. So I printed out $_POST['multiplier_textarea_2'] and saw that it is not empty. Than I found the cause. It took me 2 minutes and I don't think that any error of this type would be able to conquer me :) Try this by yourself
Flashart
Forum Commoner
Posts: 71
Joined: Tue Oct 06, 2009 12:12 pm

Re: Arrays, text areas and concatenation

Post by Flashart »

Thanks.

I think that's what I need to start incorporating. A systematic way of testing rather than just 'looking'. I will have a play with that thanks!
Flashart
Forum Commoner
Posts: 71
Joined: Tue Oct 06, 2009 12:12 pm

Re: Arrays, text areas and concatenation

Post by Flashart »

I have a new issue!

For some reason, if I enter 1 word into the keyword area and 2 into the multiplier 1 box, it will give me an extra space on the first result.

For example:

[new clothes ]
[new houses]

I looked through the code to see ifI had got any extra spaces in the concatenation and I couldn't see anything?

Code: Select all

 <?php
    
 foreach($firstArray as $key => $value)
    {
    	  foreach($secondArray as $key2 => $value2)
    	  {
    	  
    	  		//Broad code
    	  		if(isset($_POST['broad']))
    	  		
    				if(!empty($value2))					            
            	        {
                                echo ''.$value.' '.$value2.'<br/>';
                        }
                        else
                        {
                                echo ''.$value.'<br/>';
                        }
                  
                //Phrase Code      
               	if(isset($_POST['phrase']))
    				{
    				if(!empty($value2))					            
            	        {
                                echo '"'.$value.' '.$value2.'"<br/>';
                        }
                        else
                        {
                                echo '"'.$value.'"<br/>';
                        }
                     }   
                //Exact code
    			if(isset($_POST['exact']))
    				
    				if(!empty($value2))					            
            	        {
                                echo '['.$value.' '.$value2.']<br/>';
                        }
                        else
                        {
                                echo '['.$value.']<br/>';
                        }
                        
                 
                 // Broad & Phrase code     
                 if(isset($_POST['broad_phrase']))
    				
    				if(!empty($value2))
					    {
                                echo ''.$value.' '.$value2.'<br/>';
                                echo '"'.$value.' '.$value2.'"<br/>';
                        }
                        else
                        {
                                echo ''.$value.'<br/>';
								echo '"'.$value.'"<br/>';                        }
								
				 //Broad & Exact code
				 if(isset($_POST['broad_exact']))
    				
    				if(!empty($value2))					            
            	        {
                                echo ''.$value.' '.$value2.'<br/>';
                                echo '['.$value.' '.$value2.']<br/>';
                        }
                        else
                        {
                                echo ''.$value.'<br/>';
								echo '['.$value.']<br/>';                        }
								
				//Broad, Phrase & Exact code				
				 if(isset($_POST['broad_phrase_exact']))
    				
    				if(!empty($value2))
            	        {
                                echo ''.$value.' '.$value2.'<br/>';
                                echo '"'.$value.' '.$value2.'"<br/>';
                                echo '['.$value.' '.$value2.']<br/>';
                        }
                        else
                        {
                                echo ''.$value.'<br/>';
								echo '"'.$value.'"<br/>'; 
                                echo '['.$value.']<br/>';
						}
						
										
				//Phrase & Exact code				
				 if(isset($_POST['phrase_exact']))
    				
    				if(!empty($value2))
            	        {
                                echo '"'.$value.' '.$value2.'"<br/>';
                                echo '['.$value.' '.$value2.']<br/>';
                        }
                        else
                        {
								echo '"'.$value.'"<br/>'; 
								echo '['.$value.' '.$value2.']<br/>';
						}
						
						
				
            //penultimate ending curly bracket
                       }
        // ending curly bracket
        }
 
it's probably something simple, though of course I appreciate any pointers!
curlybracket
Forum Commoner
Posts: 59
Joined: Mon Nov 29, 2010 2:40 pm

Re: Arrays, text areas and concatenation

Post by curlybracket »

Additional spaces appears when you are slicing text from textarea using:

Code: Select all

$firstArray = explode("\n", $firstTextarea);
$secondArray = explode("\n", $secondTextarea);
$thirdArray = explode("\n", $thirdTextarea);
use trim() for values, like this:

Code: Select all

foreach($secondArray as $key2 => $value2)
{
  $value2 = trim($value2);
You may need this for values of other arrays.
Flashart
Forum Commoner
Posts: 71
Joined: Tue Oct 06, 2009 12:12 pm

Re: Arrays, text areas and concatenation

Post by Flashart »

Ah brilliant, thanks! OK this is all starting to make sense now. I am looking at some books as well though there seems to be very different ways of doing things!
Flashart
Forum Commoner
Posts: 71
Joined: Tue Oct 06, 2009 12:12 pm

Re: Arrays, text areas and concatenation

Post by Flashart »

Hello

I was wondering if you could help me by explaining how I can replace the buttons with checkboxes? I have tried but as usual I am missing something! (results to appear in the results div..)

Code: Select all

<?php
include ("config.php");
ini_set('display_errors', true); //Display error in browser
error_reporting (E_ALL ^ E_NOTICE);
$broad_match='unchecked';
$exact_match='unchecked';
$phrase_match='unchecked';

if (isset($_POST['Submit']));{

if (isset($_POST['exact_match'])){
	$exact_match=$_POST['exact_match'];



{

	//Variables
	$firstKwordarea = $_POST['kword_area_1'];
	$secondKwordarea = $_POST['kword_area_2'];
	$thirdKwordarea = $_POST['kword_area_3'];
	$fourthKwordarea = $_POST['kword_area_4'];
	$pre_multiplier = $_POST['pre_multiplier_area'];
	
	
	//Arrays
	$kword_1_Array = explode("\n", $firstKwordarea);
	$kword_2_Array = explode("\n", $secondKwordarea);
	$kword_3_Array = explode("\n", $thirdKwordarea);
	$kword_4_Array = explode("\n", $fourthKwordarea);
	$pre_multiplier_Array = explode("\n", $pre_Multiplier_area);
	
	
	
}






?>
<!DOCTYPE html>
<head>
<title>SGM PAB</title>
<!--<link rel="stylesheet" href="CSS/main.css" type="text/css"/>-->
<style type="text/css">
//Reset padding & Margin
*{ 
	padding: 0; 	
	margin: 0;
}


#wrapper {
	width: 900px;

}

#header {
	margin: 20px 0 0 0;
}

#left_column, #campaign, #main_content {
	float:left;
	margin: 0 5px 0 0;
}


#main_content {
	width: 250px;
}

#multipliers {
	width: 200px;
}

#results {
	width: 300px;
	
}

fieldset {
	margin: 1em o;
	padding: 1em;
	/*border: 1 px solid #ccc;	*/
	/*background: #f8f8f8;*/
	border: none;
}

legend {
	font-weight: bold;
}

label {
	display: block;
	cursor: pointer;
}

input {
	width: 15em;
}

#campaign textarea, #main_content textarea, #multipliers textarea  {
	width: 15em;
	height:10em;
	border: 1px solid #989898;
	-moz-border-radius: 6px; 
	-webkit-border-radius: 6px; 
	border-radius: 3px; bottom left repeat-x;
	-moz-box-shadow: 2px 2px 2px #ccc; 
	-webkit-box-shadow: 2px 2px 2px #ccc; 
	box-shadow: 2px 2px 2px #ccc;
	color: #000; font-size: 12px;
}

#campaign textarea {
	height: 1.5em;
	
}
.checkbox {
	width: auto;
	float: left;
	margin-right: 1em;
}


.account_structure_textarea {
	width: 3em;
	height:2em;
	border: 1px solid #989898;
	-moz-border-radius: 6px; 
	-webkit-border-radius: 6px; 
	border-radius: 3px; bottom left repeat-x;
	-moz-box-shadow: 2px 2px 2px #ccc; 
	-webkit-box-shadow: 2px 2px 2px #ccc; 
	box-shadow: 2px 2px 2px #ccc;
	
	
}

button { 
	width: 80px; 
	height: 40px; 
	border: 1px solid #989898;
	-moz-border-radius: 6px; 
	-webkit-border-radius: 6px; 
	border-radius: 26px; background: rgba(132,65,243,1) bottom left repeat-x;
	-moz-box-shadow: 2px 2px 2px #ccc; 
	-webkit-box-shadow: 2px 2px 2px #ccc; 
	box-shadow: 2px 2px 2px #ccc;
	color: #fff; font-size: 26px;
	font-weight: bold; 
	text-shadow: 1px 1px 1px #666;
}

#clear_both {
	clear:both;
}

#footer {
}

fieldset#multipliers {
	
	width:400px;
}


#multipliers h2 { 
	width: 10em; 
	font-size: 1em; 
	font-weight: normal;
	margin: 0;
	padding: 0;
}

#multipliers .col { 
	width: 12em; 
	float:left;
	clear: none; 
}

#submit {
	float: left;
	margin: 0 0 0 15px;
}

</style>
</head>

<body>
<div id="wrapper">
	<div id="content">
		<div id="header">

		<img src="images/logo.png" id="logo" />

			<!--Header wrapper div-->
	</div>
<div id="top_bar">

</div>


<div id="left_column">
	<form action="" method="post">
	<fieldset>
		<p>Match Type<p>
	<div>
<label for="broad_match">Broad
<input type="checkbox" name="match_type" id="match_type_checkbox" value="broad_match" class="checkbox" /></label>

<label for="phrase_match">Phrase
<input type="checkbox" name="match_type" id="match_type_checkbox"  value="phrase_match" class="checkbox" /></label>

<label for="exact_match">Exact
<input type="checkbox" name="match_type" id="match_type_checkbox"  value="exact_match" class="checkbox"/></label>

	</div>
</fieldset>


<fieldset>
<p>Adcode Structure</p>
<div>
<label for="account_box">Account</label>
<input type="textarea" name="account_box" class="account_structure_textarea"/>

<label for="media_box">Media</label>
<input type="textarea" name="media_box" class="account_structure_textarea"/>

<label for="channel_box">Channel</label>
<input type="textarea" name="channel_box" class="account_structure_textarea"/>

<label for="campaign_box">Campaign</label>
<input type="textarea" name="campaign_box" class="account_structure_textarea"/>
</div>
</div></fieldset>

	<div id="campaign">
		<fieldset>
			<p>Campaign</p>
			<div>
				<textarea name="campaign_textarea" id="campaign_textarea"></textarea>
		</div>
		</div></fieldset>


<div id="main_content">
<fieldset>
<p>Ad Groups & Core Keywords</p>
<div>
<textarea name="kword_area_1"></textarea><br/>
<!--<textarea name="kword_area_2"></textarea><br />
<textarea name="kword_area_3"></textarea><br />
<textarea name="kword_area_4"></textarea><br />-->

</div>
</div>

<div id="multipliers">

<fieldset id="multipliers">
		<div class="col">
		<p>	Pre-Multiplier</p>
			<textarea name="pre_multiplier_textarea"></textarea>		
			</div>
		<div class="col">
	<p>Post-Multiplier</p>

			<textarea name="post_multiplier_textarea"></textarea>		
		</div>
	
</fieldset>

</div>

<div id="submit">

<button type="submit">Go</button>

</div>

</div>




<div id="clear_both">
&nbsp;
</div>
<div id="results">
 
 
 <?php
 if ($exact_match = ='exact_match') {
 not sure what to write here!
 }
       ?>


</div>
<!-- Results div -->
<div id="footer">
SGM

</div>
<!-- Footer div close-->


	</div>
	<!-- Content div -->
	</div>
	<!-- Wrapper div -->
</body>
</html>

curlybracket
Forum Commoner
Posts: 59
Joined: Mon Nov 29, 2010 2:40 pm

Re: Arrays, text areas and concatenation

Post by curlybracket »

Few things:

Code: Select all

if ($exact_match = ='exact_match') { // parse error here, should be == instead of = =
 // not sure what to write here!
 }

Code: Select all

if (isset($_POST['Submit']));{ //  semicolon is wrong here

if (isset($_POST['exact_match'])){
        $exact_match=$_POST['exact_match'];
{ // error here - should be } ?
       //Variables
        $firstKwordarea = $_POST['kword_area_1'];
        $secondKwordarea = $_POST['kword_area_2'];
        $thirdKwordarea = $_POST['kword_area_3'];
        $fourthKwordarea = $_POST['kword_area_4'];
        $pre_multiplier = $_POST['pre_multiplier_area'];
        
        //Arrays
        $kword_1_Array = explode("\n", $firstKwordarea);
        $kword_2_Array = explode("\n", $secondKwordarea);
        $kword_3_Array = explode("\n", $thirdKwordarea);
        $kword_4_Array = explode("\n", $fourthKwordarea);
        $pre_multiplier_Array = explode("\n", $pre_Multiplier_area);
}
This is how you should check values of checboxes and set your variables:

Code: Select all

if (isset($_POST['match_type'])){
  if($_POST['match_type'] == 'exact_match') { $exact_match = 'checked'; }
  if($_POST['match_type'] == 'broad_match') { $broad_match = 'checked'; }
  if($_POST['match_type'] == 'phrase_match') { $phrase_match = 'checked'; }
}
Flashart
Forum Commoner
Posts: 71
Joined: Tue Oct 06, 2009 12:12 pm

Re: Arrays, text areas and concatenation

Post by Flashart »

Hiya thanks for that, though I am a little confused.

I have included the following section:

Code: Select all

if (isset($_POST['match_type'])){
  if($_POST['match_type'] == 'exact_match') { $exact_match = 'checked'; }
  if($_POST['match_type'] == 'broad_match') { $broad_match = 'checked'; }
  if($_POST['match_type'] == 'phrase_match') { $phrase_match = 'checked'; }
}
 
Do I now include the other variables and arrays within the curly braces here or do I set these separately? Also whereabouts do I include the submit button code? This is no doubt childs play to yourself!

I'm quite confused now on how to structure the code to get similar results to previous incarnations.

Thanks for your help!
Flashart
Forum Commoner
Posts: 71
Joined: Tue Oct 06, 2009 12:12 pm

Re: Arrays, text areas and concatenation

Post by Flashart »

Having tried variations on previous attempts with this code

Code: Select all

<?php
include ("config.php");
ini_set('display_errors', true); //Display error in browser
error_reporting (E_ALL ^ E_NOTICE);



if (isset($_POST['match_type'])){	
if ($_POST['match_type'] == 'broad_match') { $broad_match = 'checked'; }
if ($_POST['match_type'] == 'phrase_match') { $phrase_match = 'checked'; }
if ($_POST['match_type'] == 'exact_match') { $exact_match = 'checked'; }

}



if (isset($_POST['submit'])){

	$firstKwordarea = $_POST['kword_area_1'];
    $secondKwordarea = $_POST['kword_area_2'];
    $thirdKwordarea = $_POST['kword_area_3'];
    $fourthKwordarea = $_POST['kword_area_4'];
    $pre_multiplier = $_POST['pre_multiplier_area'];
      
    //Arrays
    $kword1Array = explode("\n", $firstKwordarea);
    $kword2Array = explode("\n", $secondKwordarea);
    $kword3Array = explode("\n", $thirdKwordarea);
    $kword4Array = explode("\n", $fourthKwordarea);
    $pre_multiplier_Array = explode("\n", $pre_Multiplier_area);
    }



?>
<!DOCTYPE html>
<head>
<title>SGM PAB</title>
<!--<link rel="stylesheet" href="CSS/main.css" type="text/css"/>-->
<style type="text/css">
//Reset padding & Margin
*{ 
	padding: 0; 	
	margin: 0;
}


#wrapper {
	width: 1020px;

}

#header {
	margin: 20px 0 0 0;
}

#left_column, #campaign, #keywords {
	float:left;
	margin: 0 5px 0 0;
}

#main_content {
	
	}

#keywords {
	width: 250px;
}

#multipliers {
	width: 200px;
}

#results {
	width: 300px;
	
}

fieldset {
	margin: 1em o;
	padding: 1em;
	/*border: 1 px solid #ccc;	*/
	/*background: #f8f8f8;*/
	border: none;
}

legend {
	font-weight: bold;
}

label {
	display: block;
	cursor: pointer;
}

input {
	width: 15em;
}

#keywords textarea, #main_content textarea, #multipliers textarea  {
	width: 15em;
	height:10em;
	border: 1px solid #989898;
	-moz-border-radius: 6px; 
	-webkit-border-radius: 6px; 
	border-radius: 3px; bottom left repeat-x;
	-moz-box-shadow: 2px 2px 2px #ccc; 
	-webkit-box-shadow: 2px 2px 2px #ccc; 
	box-shadow: 2px 2px 2px #ccc;
	color: #000; font-size: 12px;
}


#campaign textarea {
	height: 1.5em;
	
}
.checkbox {
	width: auto;
	float: left;
	margin-right: 1em;
}


.account_structure_textarea {
	width: 3em;
	height:2em;
	border: 1px solid #989898;
	-moz-border-radius: 6px; 
	-webkit-border-radius: 6px; 
	border-radius: 3px; bottom left repeat-x;
	-moz-box-shadow: 2px 2px 2px #ccc; 
	-webkit-box-shadow: 2px 2px 2px #ccc; 
	box-shadow: 2px 2px 2px #ccc;
	
	
}

button { 
	width: 80px; 
	height: 40px; 
	border: 1px solid #989898;
	-moz-border-radius: 6px; 
	-webkit-border-radius: 6px; 
	border-radius: 26px; background: rgba(132,65,243,1) bottom left repeat-x;
	-moz-box-shadow: 2px 2px 2px #ccc; 
	-webkit-box-shadow: 2px 2px 2px #ccc; 
	box-shadow: 2px 2px 2px #ccc;
	color: #fff; font-size: 26px;
	font-weight: bold; 
	text-shadow: 1px 1px 1px #666;
}

#clear_both {
	clear:both;
}

#footer {
}

fieldset#multipliers {
	
	width:400px;
}


#multipliers h2 { 
	width: 10em; 
	font-size: 1em; 
	font-weight: normal;
	margin: 0;
	padding: 0;
}

#multipliers .col { 
	width: 12em; 
	float:left;
	clear: none; 
}

#submit {
	float: left;
	margin: 0 0 0 15px;
}

#Adcode_structure {
}

</style>
</head>

<body>
<div id="wrapper">
	<div id="content">
		<div id="header">

		<img src="images/logo.png" id="logo" />

			<!--Header wrapper div-->
	</div>
<div id="top_bar">

</div>


<div id="left_column">
	<form action="" method="post">
	<fieldset>
		<p>Match Type<p>
	<div>
<label for="broad_match">Broad
<input type="checkbox" name="match_type" id="match_type_checkbox" value="broad_match" class="checkbox" /></label>

<label for="phrase_match">Phrase
<input type="checkbox" name="match_type" id="match_type_checkbox"  value="phrase_match" class="checkbox" /></label>

<label for="exact_match">Exact
<input type="checkbox" name="match_type" id="match_type_checkbox"  value="exact_match" class="checkbox"/></label></div>


<fieldset>
<div id="Adcode_structure">
<p>Adcode Structure</p>
<div id="col">
<label for="account_box">Account</label>
<input type="textarea" name="account_box" class="account_structure_textarea"/></div>
<div id="col">
<label for="media_box">Media</label>
<input type="textarea" name="media_box" class="account_structure_textarea"/>
</div>
<div id="col">
<label for="channel_box">Channel</label>
<input type="textarea" name="channel_box" class="account_structure_textarea"/>
</div>
<div id="col">
<label for="campaign_box">Campaign</label>
<input type="textarea" name="campaign_box" class="account_structure_textarea"/>
</div>
</div></fieldset></div>


	</div>
</fieldset>
</div>




<div id="main_content">
	<div id="campaign">
		<fieldset>
			<p>Campaign</p>
			<div>
				<textarea name="campaign_textarea" id="campaign_textarea"></textarea>
		</div>
		</div></fieldset>


<div id="keywords">
<fieldset>
<p>Ad Groups & Core Keywords</p>
<div>
<textarea name="kword_area_1"></textarea><br/>
<!--<textarea name="kword_area_2"></textarea><br />
<textarea name="kword_area_3"></textarea><br />
<textarea name="kword_area_4"></textarea><br />-->

</div>
</div>

<div id="multipliers">

<fieldset id="multipliers">
		<div class="col">
		<p>	Pre-Multiplier</p>
			<textarea name="pre_multiplier_textarea"></textarea>		
			</div>
		<div class="col">
	<p>Post-Multiplier</p>

			<textarea name="post_multiplier_textarea"></textarea>		
		</div>
	
</fieldset>

</div>

<div id="submit">

<button type="submit">Go</button>

</div>

</div>
</div>
<!-- main content div -->



<div id="clear_both">
&nbsp;
</div>
<div id="results">
 <?php


	if(isset($_POST['exact_match']));
		{	
			foreach ($kwordArray1 as $key => $value)
				{
				
			echo '['.$value.']<br />';
			}
			}
 
 		
 
 ?>

</div>
<!-- Results div -->
<div id="footer">
SGM

</div>
<!-- Footer div close-->


	</div>
	<!-- Content div -->
	</div>
	<!-- Wrapper div -->
</body>
</html>

I get an error:

Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/PPC_Account_Builder/concat_test_3.php on line 309

I can't seem to figure this out! Can anyone help? thanks in advance.
curlybracket
Forum Commoner
Posts: 59
Joined: Mon Nov 29, 2010 2:40 pm

Re: Arrays, text areas and concatenation

Post by curlybracket »

First occurence of variable $kwordArray1 is here:

Code: Select all

foreach ($kwordArray1 as $key => $value)
So this variable does not exist earlier in the code and of course it's not an array - foreach needs an array.
Post Reply