Page 1 of 1

Add results from database in form address

Posted: 31 Mar 2021, 03:54
by JanMolendijk
Hello Coursesweb

I have a problem to get results from the database into input type text form in the place name.

Code: Select all

name="id='. $row1['id']. '&limit1"

I hope to get this result in the browser-url

name="id=19&limit1=10"

But I getting this result in url

Backup-Limit.php?id%3D19%26limit1=10

Code: Select all

<?php
// connect to the "tests" database
$conn = new mysqli('127.0.0.1', 'course_chat', '123456', 'course_chat');
// check connection
if (mysqli_connect_errno()) {
  exit('Connect failed: '. mysqli_connect_error());
}
// SELECT sql query
$sql = "SELECT * FROM `ajax_chat_title` ORDER BY `ajax_chat_title`.`id` DESC LIMIT 3"; 
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
  // output data of each row from $result
  while($row1 = $result->fetch_assoc()) {
    echo '<div class="'. $row1['id']. ' selectt"> 

<div class="search-box">
<form id="tfnewsearch" autocomplete="off" method="get" action="//145.53.93.209/Molendijk/Member/Backup/Backup-Limit.php?" target="_top">
   <input type="submit" target="offtopic1" value="search" class="tfbutton"> 

     <input type="text" style=""  id="fname" class="tftextinput" name="id='. $row1['id']. '&limit1" size="21" placeholder="Search Members..." maxlength="120" />
<br>
    <div class="result"></div> </form>
    </div>
    <strong>'. $row1['text']. '</strong> 
          </div>' ;

  }
}
else {
  echo 'No-one added yet a @1';
}
$conn->close();
?></div>
Hope you can help me out.

Add results from database in form address

Posted: 31 Mar 2021, 06:51
by MarPlo
For what you want to get; if you want to add the $row['id'] in the form url address, put the code to the address from the "action" attribute.

Code: Select all

<form id="tfnewsearch" autocomplete="off" method="get" action="//145.53.93.209/Molendijk/Member/Backup/Backup-Limit.php?id='. $row1['id']. '&limit1=10" target="_top">
<input type="submit" value="search" class="tfbutton">
<input type="text" id="fname" class="tftextinput" name="fname" size="21" placeholder="Search Members..." maxlength="120" /><br>
<div class="result"></div></form>

Add results from database in form address

Posted: 31 Mar 2021, 07:45
by JanMolendijk
Thanks for the super-quick suport

If I do it in the action I don`t get any result
I need to have the results from database in input name

Because from the input text (name)
I drop a number to get the limit

Code: Select all

<input type="text" style=""  id="fname" class="tftextinput" name="id='. $row1['id']. '&limit1" size="21" placeholder="Search Members..." maxlength="120" />
When I press search I get this result

Code: Select all

http://145.53.93.209/Molendijk/Member/Backup/Backup-Limit.php?id%3D22%26limit1=10
But the result must be like this

Code: Select all

http://145.53.93.209/Molendijk/Member/Backup/Backup-Limit.php?id=4400&limit1=30


Full code under (with select item)

Code: Select all

    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> 
    
<?php
// connect to the "tests" database
$conn = new mysqli('127.0.0.1', 'course_chat', '123456', 'course_chat');
// check connection
if (mysqli_connect_errno()) {
  exit('Connect failed: '. mysqli_connect_error());
}
// SELECT sql query
$sql = "SELECT * FROM `ajax_chat_title` ORDER BY `ajax_chat_title`.`id` DESC LIMIT 3"; 
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
  // output data of each row from $result
  while($row = $result->fetch_assoc()) {
    echo '

<style type="text/css"> 
        .selectt { 
            color: #000000; 
            padding: 3px; 
            display: none; 
            margin-top: 30px; 
            width: 40%; 
            background: white; 
        } 
          
        label { 
            margin-right: 20px; 
        } 
    </style> 


 <div> 
            <label> <img src="http://145.53.93.209/Molendijk/Members/'. $row['id']. '.jpg" border="none" width="40" height="40"></img> 
                <input type="checkbox" name="colorCheckbox" 
                       value="'. $row['id']. '">'. $row['text']. '</label> 
           
                </div> 
      
 ' ;

  }
}
else {
  echo 'No-one added yet a @1';
}
$conn->close();
?>

Code: Select all

<div class="venster"><button>Post Selected Members</button>
<?php
// connect to the "tests" database
$conn = new mysqli('127.0.0.1', 'course_chat', '123456', 'course_chat');
// check connection
if (mysqli_connect_errno()) {
  exit('Connect failed: '. mysqli_connect_error());
}
// SELECT sql query
$sql = "SELECT * FROM `ajax_chat_title` ORDER BY `ajax_chat_title`.`id` DESC LIMIT 3"; 
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
  // output data of each row from $result
  while($row1 = $result->fetch_assoc()) {
    echo '

 <div class="'. $row1['id']. ' selectt"> 
       <img src="http://145.53.93.209/Molendijk/Members/'. $row1['id']. '.jpg" border="none" width="40" height="40"></img>

<div class="search-box">
<form id="tfnewsearch" autocomplete="off" method="get" action="http://145.53.93.209/Molendijk/Member/Backup/Backup-Limit.php?id='. $row1['picture_id']. '" target="_top">
   <input type="submit" target="offtopic1" value="search" class="tfbutton"> 

     <input type="text" style=""  id="fname" class="tftextinput" name="id='. $row1['picture_id']. '&limit1" size="21" placeholder="Search Members..." maxlength="120" />  
 
<br>
    <div class="result"></div> </form>
    </div>

<br>
    <div class="result">
</div>

    <strong>'. $row1['text']. '</strong> 
          </div> 

 ' ;


  }
}
else {
  echo 'No-one added yet a @1';
}
$conn->close();
?></div>





        <script type="text/javascript"> 
            $(document).ready(function() { 
                $('input[type="checkbox"]').click(function() { 
                    var inputValue = $(this).attr("value"); 
                    $("." + inputValue).toggle(); 
                }); 
            }); 
        </script> 
  


<script>

var inputBox = document.getElementById('fname');

inputBox.onkeyup = function(){
    document.getElementById('printchatbox').innerHTML = inputBox.value;
}

</script>
I hope I made it understandble

Add results from database in form address

Posted: 31 Mar 2021, 08:21
by MarPlo
You cannot add two name identifiers (id and limit1) into a single 'name' attribute.
You must create a form field for each name.
For example, you can add a hidden input field for id, and the text field for limit1.

Code: Select all

<form id="tfnewsearch" autocomplete="off" method="get" action="//145.53.93.209/Molendijk/Member/Backup/Backup-Limit.php" target="_top">
<input type="hidden" name="id" value="'. $row1['id']. '">
<input type="submit" value="search" class="tfbutton">
<input type="text" id="fname" class="tftextinput" name="limit1" size="21" placeholder="Search Members..." maxlength="120" /><br>
<div class="result"></div></form>

Add results from database in form address

Posted: 31 Mar 2021, 08:27
by JanMolendijk
Marplo thanks thanks thanks for all suport
& even so quick suport `thanks again`

it is working

I could kiss you :D