Answer the question
In order to leave comments, you need to log in
What am I doing wrong?
I create a crud application, it should read all the data from three tables on the main page.
I made an array in index.php
<?php foreach ($result as $value) { ?>
<tr>
<td><?=$value->id ?></td>
<td><a href="<?=$value->url ?>" target="_blank"><?=$value->title ?></a></td>
<td><a href="<?=$value->url_type ?>" target="_blank"><?=$value->title_type ?></a></td>
<?php } ?>
$get_id = $_GET['id'];
$get_type_id = $_GET['type_id'];
$get_category_id = $_GET['category_id'];
$get_title = $_GET['title'];
$get_url = $_GET['url'];
$get_time = $_GET['time'];
//Read xf_list
$sql = $pdo->prepare("SELECT * FROM xf_list");
$sql->execute();
$result = $sql->fetchAll(PDO::FETCH_OBJ);
$get_type_id = $_GET['id'];
$get_type_title = $_GET['title_type'];
$get_type_url = $_GET['url_type'];
//Read xf_type
$sql = $pdo->prepare("SELECT * FROM xf_type");
$sql->execute();
$result = $sql->fetchAll(PDO::FETCH_OBJ);
$get_category_id = $_GET['id'];
$get_category_title = $_GET['title'];
//Read xf_category
$sql = $pdo->prepare("SELECT * FROM xf_category");
$sql->execute();
$result = $sql->fetchAll(PDO::FETCH_OBJ);
$get_id = $_GET['id'];
$get_type_id = $_GET['type_id'];
$get_category_id = $_GET['category_id'];
$get_title = $_GET['title'];
$get_url = $_GET['url'];
$get_time = $_GET['time'];
//Read xf_list
$sql = $pdo->prepare("SELECT * FROM xf_list");
$sql->execute();
$result1 = $sql->fetchAll(PDO::FETCH_OBJ);
<?php foreach ($result as $value) { ?>
<tr>
<td><?=$value->id ?></td>
<td><a href="<?=$value->url ?>" target="_blank"><?=$value->title ?></a></td>
<?php } ?>
</tr>
type_id
<td><a href="<?=$value->url_type ?>" target="_blank"><?=$value->title_type ?></a></td>
category_id
<td>
=$value->title_category </td>
Answer the question
In order to leave comments, you need to log in
Forgot to learn databases.
read: third normal form.
you have three tables.
in one data. and two guides.
it is necessary to write request to three tables.
Select .... from _data_ join _sprav_ on field from the data table = reference.id
and in the reference, as I think, there is also a field with a category code, which also needs to be expanded to the name
And this is natural, since with each subsequent request you overwrite the $result variable.
You need to get each request into your variable $result1, $result2, $result3, then combine them into one and pass it to the renderer.
Just thinking out loud:
this is
$get_type_id = $_GET['id'];
should not be:
$get_type_id = $_GET['type_id'];
question?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question