Keslaw
(Keslaw123)
January 16, 2016, 6:30pm
1
Hi,
I created databases using Gii/Yii and generated CRUD. I can’t find one specific thing. So, I want to put number (its ID of my database - see attachment) to textfield next to the button ‘Wczytaj klienta’ and then I want to click button ‘Wczytaj klienta’ to fill all fields below things which I meant before. I know how to connect to database, what’s next? Can you give me an example?
Thank you in advance.
Keslaw
(Keslaw123)
January 16, 2016, 8:09pm
3
O to chodziło, dzięki bardzo!
Keslaw
(Keslaw123)
January 17, 2016, 6:40pm
4
So, I created this:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "wypozyczalnia";
$conn = new mysqli($servername, $username, $password, $database);
if ($conn->connect_error) {
echo "Not connected, error: " . $mysqli_connection->connect_error;
}
echo '<input ', (isset($IDklienta['IDklienta']) ? 'value="'.$IDklienta['IDklienta'].'"' : ''), '/>' ;
echo "</br>";
$result = mysqli_query($conn,"SELECT * FROM klienci");
if($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>";
echo "Imie: ";
echo $row['Imie'];
echo "</td>";
echo "</br>";
echo "<td>";
echo "Nazwisko: ";
echo $row['Nazwisko'];
echo "</td>";
//these are the fields that you have stored in your database table employee
echo "</br>";
echo "</tr>";
}
mysqli_close($conn);
?>
How to make
if($row = mysqli_fetch_array($result))
related to:
echo '<input ', (isset($IDklienta['IDklienta']) ? 'value="'.$IDklienta['IDklienta'].'"' : ''), '/>' ;
When i put correct IDklienta in this input, I want to display rest of the rows listed.
Pabloss
(Heros68)
January 17, 2016, 9:50pm
5
here you have answer https://www.youtube …Lx2mkF&index=24
if you click button, your data will be loading to input through ajax script from database.
p.s you don’t need create a new connect to database becouse you already j have in common/config.php If you use advanced template