jeff5656 Posted December 1, 2008 Share Posted December 1, 2008 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>"; } } Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 1, 2008 Share Posted December 1, 2008 can we see $row Quote Link to comment Share on other sites More sharing options...
jeff5656 Posted December 1, 2008 Author Share Posted December 1, 2008 $consultsq1 = "SELECT * FROM `staffsched` WHERE `which_month`='".$curr_month."'"; $result = mysql_query ($consultsq1) or die ("Invalid query: " . mysql_error ()); $row = mysql_fetch_array ($result); Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 1, 2008 Share Posted December 1, 2008 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>"; } Quote Link to comment Share on other sites More sharing options...
jeff5656 Posted December 1, 2008 Author Share Posted December 1, 2008 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]."'; ?> />"; Quote Link to comment Share on other sites More sharing options...
btherl Posted December 1, 2008 Share Posted December 1, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.