This Question have 3 answers right now.

Assign value of a button for each row

Tags: php

I am trying to use php and I am really new to it.

I create one page that (with a php code) send the info to the database and one page that display the info from the databse.

My question is: Lets say I am going to input 10 info , but I am displaying just 5 of them, how can I display the rest of the info clicking to a button for each row?

Do I have to assign to the button a value? I cant understand how I can relate the button to the row.

Basically for each row I want to display the rest of the info of that specific row clicking on that specific button.

Any help will be appricciate. thanks

----- script that insert the info in the db-----


$name = mysqli_real_escape_string($link, $_POST['name']);
$mail = mysqli_real_escape_string($link, $_POST['mail']);
$number = mysqli_real_escape_string($link, $_POST['number']);
$device = mysqli_real_escape_string($link, $_POST['device']);
$model = mysqli_real_escape_string($link, $_POST['model']);
$problem = mysqli_real_escape_string($link, $_POST['problem']);

        $sql = "INSERT INTO cj (name, mail, number, device, model, problem) VALUES ('$name', '$mail', '$number', '$device', '$model', '$problem')";
        $result = mysqli_query($link, $sql);
        // if query fails stop script and echo error
    if( $result === false)
    {echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
    header("location:add-customer.php?message=A job and customer has been added to the database");

        echo "You'll never see this";

----------- page that shows the info ------

$sql = "SELECT * from "database name"";
    echo "
<table class='table'>
/* Get field information for all columns */

    echo "<form action='' method=post>";
    echo "<tr class='info'>

                 <input type=hidden name=hidden value=" . $row['id'] . ">
                <td>" . $row['id'] . "</td> 
                <td>" . $row['device'] . "</td>
                <td>" . $row['model'] . "</td> 
                <td>" . $row['problem'] . "</td>


                <a class='btn btn-primary btn-sm'  data-toggle='modal' data-target='#myModal' value= " . $row['id'] . " >  Info</a></form></td>

    echo "</form>";

echo "



<div class="container">
  <!-- Trigger the modal with a button -->
  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog modal-lg">
  <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Customer Information</h4>

        <div class="modal-body">

if ($link->connect_errno > 0) {
    die('Unable to connect to database [' . $link->connect_error . ']');
$sql = "SELECT name,mail,number from databasename WHERE **???**;

if (!$result = $link->query($sql)) {

    die('There was an error running the query [' . $link->error . ']');
echo "
<table class='table'>
/* Get field information for all columns */
while ($finfo = $result->fetch_field()) {
    echo "
        <th>" . $finfo->name . "</th>";
echo "
while ($row = $result->fetch_assoc()) {
    echo "<tr class='info'>

                <td>" . $row['name'] . "</td>
                <td>" . $row['mail'] . "</td>
                <td>" . $row['number'] . "</td>




Connect to datatabase and get all 10 info with PHP. But show only 5 info. Put a button there, and use Javascript or Jquery to show other rows. (Onclick event)

By : Mubariz

Here is what I will do,

1st, get the array of selected rows by using indexPathsForSelectedRows,

2nd, iterate the array to check if if indexPath.row is 1 or 2.

3rd, if your if statement's condition is true, then do ...

If I am reading this correctly, Message would contain a List<MessageUser>.

If that's the case then this should get you close:

var List<Message> messages = 
    ( from m 
      in db.Messages 
          m.UserID == userid || m.MessageUsers.Any(mu => mu.UserID == userID) 
      select m).ToList();
By : Sam Axe

Best way to access Exchange using PHP?

Encrypting Passwords

Connect PHP to IBM i (AS/400

Are PHP Variables passed by value or by reference?

Make XAMPP/Apache serve file outside of htdocs [closed]

How can I get the authenticated user name under Apache using plain HTTP authentication and PHP?

Using object property as default for method property

Mechanisms for tracking DB schema changes [closed]

How can I get at the matches when using preg_replace in PHP?

Why is my ternary expression not working?

File size differences after copying a file to a server vía FTP

MySQL/Apache Error in PHP MySQL query

PHP Error - Uploading a file

Multi-Paradigm Languages

Video about Assign value of a button for each row