Yevgeniy Bagackiy Yevgeniy Bagackiy - 1 month ago 7
PHP Question

How to get full string value from database?

What i have is form. Inside form there is list of checkboxes, data for this checkboxes is taken from database. Here is some data from

theme_name
column:

| theme_name |
+------------+
| BGD LYT |
| BGD COL |
| BLD RIG |
| BLD SWB |
| CGI ANM |
| CGI MOD |


I am able to get this data and print it for user :

<form method="post" action="createProject2.php">
<?php
$result = getProcessID();
?>
<div class="scrollable" id="checkboxes">
<?php
while ($row = mysqli_fetch_array($result))
{
$row[0] = cleanOutputData($row[0]);
?>
<input type="checkbox" class="checkbox" name="process[]" id=<?php echo $row[0] ?> value=<?php echo $row[0]?> /><?php echo $row[0] ?>

<?php
}
mysqli_free_result($result);
?>
</div>

<input type = "submit" name ="submit" class="button" onclick="userSubmitted = true;" value = "Continue"/>

</form>


But what im getting on page
createProject2.php
is:

<?php
$proc = isset($_POST['process'])?$_POST['process']:'';
$len = count($proc); // getting length of ur array that u need to condition ur loop
?>

<?php
//an array of inputs
for($y=0;$y<$len;$y++)
{
?>
<input type='text' name='holdprocess[]' value="<?php echo $proc[$y]?>">
<?php
}
?>


And instead of for example
BGD LYT
i get just
BGD
. And same for all values. How i can get full value of the string? Thank you

Answer

You did not use double quotes to enclose the input value.

I.e.

value=ABC DEF

html will treat value to be ABC and DEF as another attribute.

Use double quotes instead.

value="ABC DEF"
Comments