AJAX/Javascript??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I know that this might be an Ajax/Javascript question. Hopefully you can help. I do not know of any other source for good info.

I would like to be able to click on one field in a table, and retrieve the data in another field. Here is the information:

The table is:

+----------+----------------------+------+-----+---------+-------+
| Field    | Type                 | Null | Key | Default | Extra |
+----------+----------------------+------+-----+---------+-------+
| Cust_Num | smallint(5) unsigned | NO   | PRI | NULL    |       |
| Fname    | varchar(25)          | NO   |     | NULL    |       |
| Lname    | varchar(25)          | NO   |     | NULL    |       |
| Street   | varchar(25)          | NO   |     | NULL    |       |
| City     | varchar(25)          | NO   |     | NULL    |       |
| State    | varchar(2)           | NO   |     | NULL    |       |
| Zip      | mediumint(9)         | NO   |     | NULL    |       |
| Phone    | int(10)              | NO   |     | NULL    |       |
| Date     | date                 | NO   |     | NULL    |       |
| Notes    | text                 | YES  |     | NULL    |       |
| P1       | int(3)               | YES  |     | NULL    |       |
| P2       | int(3)               | YES  |     | NULL    |       |
| P3       | int(4)               | YES  |     | NULL    |       |
+----------+----------------------+------+-----+---------+-------+

Click on Lname and retrieve the Cust_Num.

Here is the sql query that will be used:

$sql12 = 'SELECT Cust_Num, Fname, Lname, Street, City, State, Zip, Phone, Notes FROM Customers WHERE Cust_Num = $_POST['Cust_Num'];

[I'm actually doing this w/ prepared statements]

                $i = 0;
                    do
                    {
                        {

$vara2 = array(array($Cust_Num, $Fname, $Lname, $Street, $City, $State, $Zip, $Phone, $Notes));
                            $vara2[$i][0]    = $Cust_Num;
                            $vara2[$i][1]    = $Fname;
                            $vara2[$i][2]    = $Lname;
                            $vara2[$i][3]    = $Street;
                            $vara2[$i][4]    = $City;
                            $vara2[$i][5]    = $State;
                            $vara2[$i][6]    = $Zip;
                            $vara2[$i][7]    = $Phone;
                            $vara2[$i][8]    = $Notes;

                            $_SESSION['exe'] = 2;

?>
<tr>
<td class="cn"> <?php echo $vara2[$i][0]?> </td>
<td> <?php echo $vara2[$i][1]?> </td>
<tdclass="ln"> <?php echo $vara2[$i][2]?> </td>
<td> <?php echo $vara2[$i][3]?> </td>
<td> <?php echo $vara2[$i][4]?> </td>
<td> <?php echo $vara2[$i][5]?> </td>
<td> <?php echo $vara2[$i][6]?> </td>
<td> <?php echo $vara2[$i][7]?> </td>
<td class="first-col"><?php echo $vara2[$i][8] ?></td>
<?php
                            echo "</tr>\n";
                            $i = $i + 1;
                            }
                        } while (mysqli_stmt_fetch($stmt)); //end do-while
                        $imax = $i;
                        echo "</table>";
                        echo "</center>";

                        }    //    end count($errors_array)


Any ideas?

Eitan



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux