Jump to content

help with " and ' placement


jeff5656

Recommended Posts

I want to put an input field from a form into this array but the quotation marks are so confusing.  Can someone tell me the best way to do this:

 

echo "<form action='commit.php' method='post'>";
echo "<tr><td ><table >";
$varArray = array("which_date");
$varArraySize = count($varArray);

for ($i = 0; $i < $varArraySize;$i++) {

   for ($f = 1; $f < 32; $f++) {
     

 echo "<td style='border-bottom-style: solid;'> " 
 echo "<input name='$row[$varArray[$i] . $f]' type='text' size='13' value= '$row[$varArray[$i] . $f]'/>";
 echo "</td>";
 echo "<tr>";
   }
   

}

Link to comment
https://forums.phpfreaks.com/topic/134929-help-with-and-placement/
Share on other sites

while not just do

 

<?php
echo "<form action='commit.php' method='post'>";
echo "<tr><td ><table >";
$consultsq1 = "SELECT * FROM `staffsched` WHERE `which_month`='".$curr_month."'";
result = mysql_query ($consultsq1) or die ("Invalid query: " . mysql_error ());

while($row = mysql_fetch_assoc($result)){
     foreach($row as $key=>$value){
    echo "<td style='border-bottom-style: solid;'> "
    echo "<input name='".$key."' type='text' size='13' value= '".$value."'/>";
    echo "</td>";
}
}
?>

    echo "<tr>";

  }

 

 

Because the variables are way to complicated.  They have names like icufellow1 icufellow2 all the way to 31 and there are 10 oif these.  With you method I get 1 row that scrolls all the way across.

The method I have works for the display but how do I do this line:

 

echo "<input name='".$row[$varArray[$i] . $f]."' type='text' size='13' value= '".$row[$varArray[$i] . $f]."'; ?> />";

 

or maybe

	 echo "<input name='"$row[$varArray[$i] . $f]"' type='text' size='13' value= '".$row[$varArray[$i] . $f]."'; ?> />";

This looks fine to me, as you had in your last post:

 

echo "<input name='".$row[$varArray[$i] . $f]."' type='text' size='13' value= '".$row[$varArray[$i] . $f]."'; ?> />";

 

An alternative is this syntax:

 

echo "<input name='{$row[$varArray[$i] . $f]}' type='text' size='13' value= '{$row[$varArray[$i] . $f]}'; ?> />";

 

Is that what you're looking for?  I find the {} syntax to be least confusing, as it lets you do just about anything inside.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.