Code out of position

<!DOCTYPE html>
<html lang="es">
<head>
<title> App Presupuesto</title>
<meta charset="utf-8">
<style>
.container{ 
    padding:20px;
}
select{
    font-size:16px;
    padding: 4px 8px;
    color: #666;
    margin-right:20px;
}
select:last-child{
    margin-right: 0;
}
</style>
<script src="js/jquery-3.4.1.js"></script>
<script>
    $(document).ready(function(){
        $('#type').on('change', function(){
            var typeID = $(this).val();
            if(typeID){
                $.ajax({
                    type:'POST',
                    url:'ajaxData.php',
                    data:'type_id='+typeID,
                    success:function(html){
                        $('#module').html(html);
                    }
                });
            }else{
                $('#module').html('<option value="">Select Type First</option>');
            }
        });

    });
</script>
<script>
    $(document).ready(function(){
        $("input[type='radio']").click(function(){
        var registration = $('input[name="registration"]:checked').val();
        if(registration){
            if(registration=="yes")
            $('#selectregis').show();
            else
            $('#selectregis').hide();
            }
        });

    });

</script>
<link href="https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/js/select2.min.js"></script>
<script src="js/select2.js"></script> 

</head>
<body>
<div class="container">
    <?php
    $type = $_POST['type'];
    include_once 'dbConfig.php';
    $selecao = "SELECT DISTINCT module.module, concept.module_id FROM concept, module WHERE module.module_id = concept.module_id AND FIND_IN_SET('" . $type . "', concept.type_id)";
    $result = $db->query($selecao) or die($db->error);
    
    ?>
    <form action="view.php" method="POST">   
        <?php while ($row = $result->fetch_array()) { ?>
        <?php var_dump($row['module_id']) ?>
        <?php switch ($row['module_id']) {
            case 1 : ?>
                <h2> Do u need Registration & Authorization? </h2>   
                <div id='div_container'>
                    <input type="radio" name="registration" value="yes">Yes<br/>
                    <input type="radio" name="registration" value="no">No<br/>
                </div>
                <div id="selectregis" style="display: none">
                <?php 
                $consulta = "SELECT concept.concept, hours_dev_time , concept.required FROM concept, module WHERE module.module_id = concept.module_id AND FIND_IN_SET('Registration & Authorization', module.module) > 0 AND concept.type_id = 1 AND concept.platform_id = 1";

                if ($resultado = $db->query($consulta)) {?>
                    <table class="table"> 
                            <tr bgcolor="#ddd">    
                                <td>Concept</td>
                                <td>Hours Dev-Time</td> 
                            </tr>            
                    <?php while ($row = $resultado->fetch_assoc()) { ?>
                            <tr>
                                <td><input type="checkbox" name="concept[]" <?php if ($row['required'] == 1) { echo "checked disabled"; } ?>  value="<?php $row['concept'] ?>"><?php echo $row['concept'] ?><br/>
                                <td><?php echo $row['hours_dev_time'] ?><br/>                   
                            </tr>
                <?php
                }
                $resultado->free();
            } ?>
            </div>
        <?php break;
        case 2 : ?>
            <?php echo "ola"; ?>
            <?php echo "Mundo"; ?>

        <?php break;
        } }?>
    <input type="submit" value="Submit">       
   </form>
</div>
</body>
</html>

When i run the code it shows like this
44

OK, looks like what you told the computer to do. That’s fine… or isn’t it?

No , because i wanted the read after the table, like
Do u need Registration?
Yes
No
–>TABLE
–> “string(1)“2” Ola mundo …”

So you need to rearrange the placement of the code. That simple.

i wanted to know how pls

You want to know how to cut code and paste it somewhere else?

My observations of your page…

  1. You are mingling PHP and HTML way too much as you should try to keep PHP and HTML separated as much as possible. It’s easier to debug and easier to read.
  2. A HTML table has no business being inside a form, from what I can decipher you can easily do this without a table with less or about the same HTML.
  3. Put you jQuery library down at the bottom of the page, but personally I would scrap jQuery and just use Vanilla JavaScript.

The most interesting thing about this to me: This looks like it is a form to get a consultation estimate for development work, but cut and paste is too complicated?

Sponsor our Newsletter | Privacy Policy | Terms of Service