I have tried to pass html as value with POST method for each post. The variable/custom field "tech_specs" contains a table in html:
<table>
<tbody>
<tr>
<td style>.....</td>
<td style>...</td>
</tr>
<tr>
<td style>....</td>
<td>....</td>
</tr>
</tbody>
</table>
The form gets
echo "<form method='post' action='.../comparison-page/' >";
while (have_posts()) : the_post();
$my_id= get_the_ID();
$tech_spec = get_post_meta($my_id, 'tech_specs');
echo "<input type='checkbox' name=\"comparison[".$i_meta."]\" value=\"".$tech_spec."\" />";
$i_meta++;
endwhile;
echo "<input type='submit' name='submit' value='Submit'/>";
echo "</form>";
As seen in the picture, html to value in the checkboxes I get value="Array". The problem, I am facing is "Array to string conversion". How can I transfer the values (html table for each value) so I can parse them in another page through the table comparison?
In your code you can add an print_r to see what in the variable $tech_spec,
$tech_spec = get_post_meta(get_the_ID(), 'tech_specs');
print_r($tech_spec);
//will return something like these :
//Array ( [key_1] => Array ( [0] => value_1 ), [key_2] => Array ( [0] => value_2 ) )
Extract what you want from the array $tech_spec.
In your echo you can put something like these :
echo "<input type='checkbox' name=\"comparison[".$i_meta."]\" value=\"".$tech_spec['key_1']."\" />";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.