I am not quite sure what the red line of code is supposed to do.
$output[] = '<td>';
echo "<input type='text' name='Value[{$row['id']}]' value='{$row['value']}'>";
$output[] = '</td>';
$output[] = '<td>';
echo "<input type='checkbox' name='Update[{$row['id']}]' value='Box #{$row['id']}'>";
$output[] = '</td>';
Is that what you were looking for, or did you want the whole thing in one string like this
$output[] = '<td>'."<input type='text' name='Value[{$row['id']}]' value='{$row['value']}'>".'</td>';
$output[] = '<td>'."<input type='checkbox' name='Update[{$row['id']}]' value='Box #{$row['id']}'>".'</td>';
Both of these should compile, but whether or not they actually do what you want them to is another story.
Gerbiler
Junior Poster in Training
81 posts since Nov 2010
Reputation Points: 12
Solved Threads: 14
Skill Endorsements: 0
@stonybony
Then why did you put a semi-colon in the middle of it? It seemed as though it was supposed to be 2 lines, the way you put it.
Anyway, is this thread solved?
Gerbiler
Junior Poster in Training
81 posts since Nov 2010
Reputation Points: 12
Solved Threads: 14
Skill Endorsements: 0
You should not use '[]' by repeating in the loop. The '[]' will generate array room every time you assign it. You have 7 elements each time mysql_fetch looping. Specify the index for one looping. For example:
$count = 0;
while ($row = $result->fetch()) {
$output[$count] = '<tr>';
$output[$count] .= '<td>'.$row['manufacturer'].'</td>';
$output[$count] .= '<td>'.$row['model'].'</td>';
$output[$count] .= '<td>'.$row['description'].'</td>';
$output[$count] .= '<td>$'.$row['price'].'</td>';
$output[$count] .= '<td><input type="text" name="Value[{'.$row['id'].'}]" value="{'.$row['value'].'}"></td>';
$output[$count] .= '<td><input type="checkbox" name="Update[{'.$row['id'].'}]" value="Box #{'.$row['id'].'}"></td>';
$output[$count] .= '<td><a href="cart.php?action=add&id='.$row['id'].'&product='.$product.'">Add to list</a><td>';
$output[$count] .= '</tr>';
$count++;
}
Don't forget to put '.' to assign new value to the array element. If not, the last will override the first one and so on. You can easily check the array with 'var_dump($input)', and ensure that your data entered in the array.
ko ko
Practically a Master Poster
673 posts since Jan 2009
Reputation Points: 120
Solved Threads: 152
Skill Endorsements: 1
Can you mark this thread as solved? I'm a bit pedantic that way. Thanks.
Gerbiler
Junior Poster in Training
81 posts since Nov 2010
Reputation Points: 12
Solved Threads: 14
Skill Endorsements: 0
Question Answered as of 2 Years Ago by
Gerbiler
and
ko ko it works like this.
for($array as $value){
$newarray[] = "1";
$newarray[] = "2";
}// that is the same as
for($array as $value){
$newarray[$counter] ="1";
$counter++
$newarray[$counter] = "2";
$counter++;
}
Gerbiler
Junior Poster in Training
81 posts since Nov 2010
Reputation Points: 12
Solved Threads: 14
Skill Endorsements: 0