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
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>";

  }

 

 

Link to comment
Share on other sites

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]."'; ?> />";

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.