To display a field from a table?

Hi all!
You will not prompt how there to field link_type from links tables ?
/* ===Widgets - receiving array=== */
informer function(){
 $query = "SELECT * FROM links
 INNER JOIN informers ON
 links.parent_informer = informers.informer_id
 ORDER BY informer_position, links_position";
 $res = mysql_query($query) or die(mysql_query());

 $informers = array();
 $name = "; // a flag named widget
 while($row = mysql_fetch_assoc($res)){
 if($row['informer_name'] != $name){ // if this widget in the array yet
 $informers[$row['informer_id']][] = $row['informer_name'];
 $informers[$row['informer_id']][] = $row['informer_id'];

 $name = $row['informer_name'];
}
 $informers[$row['parent_informer']]['sub'][$row['link_id']] = $row['link_name']; 
 // $informers[$row['parent_informer']]['link_type'] = $row['link_type']; 
 // put the page in a widget
}
 return $informers;
}
/* ===Widgets - receiving array=== */
March 19th 20 at 09:20
1 answer
March 19th 20 at 09:22
The function returns an array $informers, and it lacks link_type.
In loop put in array value
An example can show ? - alf.Bashirian commented on March 19th 20 at 09:25
@alf.Bashirian,

while($row = mysql_fetch_assoc($res)){
 if($row['informer_name'] != $name){ // if this widget in the array yet
 $informers[$row['informer_id']][] = $row['informer_name'];
 $informers[$row['informer_id']][] = $row['informer_id'];
 $informers[$row['informer_id']]['sub'] = $row['link_type']; 
 $name = $row['informer_name'];
}
 $informers[$row['parent_informer']]['sub'][$row['link_id']] = $row['link_name']; 
 // $informers[$row['parent_informer']]['link_type'] = $row['link_type']; 
 // put the page in a widget
 }
- Gus.Murray commented on March 19th 20 at 09:28
no it does not poluchaetsya https://vk.cc/9ebwIL because we got displays link_type here https://vk.cc/9ebwRW - alf.Bashirian commented on March 19th 20 at 09:31
that is, in the site we need to display link_type rather than the main category - alf.Bashirian commented on March 19th 20 at 09:34
@alf.Bashirian, corrected code, try it - Gus.Murray commented on March 19th 20 at 09:37
nope https://vk.cc/9ebzj1 - alf.Bashirian commented on March 19th 20 at 09:40
view here
<!-- Widgets -->
 <?php foreach($informers as $informer): ?>
 <div class="info">
<h3><?=$informer[0]?></h3>
 <?php foreach($episodes['sub'] as $key => $sub): ?>
 <p>- <a href="<?=PATH?>informer/<?=$key?>"><?=$sub?></a></p>
 <?php endforeach; ?>
 </div> <!-- .info -->
 <?php endforeach; ?>
 <!-- Widgets -->
- alf.Bashirian commented on March 19th 20 at 09:43
maybe the type is not as displayed as it should
what do you say ? - alf.Bashirian commented on March 19th 20 at 09:46
@alf.Bashirian, are not displayed correctly, but the link populated with more and key, I don't know the logic of your script - Gus.Murray commented on March 19th 20 at 09:49
the links do not pay attention
I thing withdraw link_type - alf.Bashirian commented on March 19th 20 at 09:52
@alf.Bashirian, which should be used link_type? - Gus.Murray commented on March 19th 20 at 09:55
Here in this cycle https://vk.cc/9ebFOs - alf.Bashirian commented on March 19th 20 at 09:58
that is, the second cycle https://vk.cc/9ebG8s - alf.Bashirian commented on March 19th 20 at 10:01
@alf.Bashirian, in the cycle moved $informer['sub'], but $informer['sub'], array - Gus.Murray commented on March 19th 20 at 10:04
@alf.Bashirian, I'm talking about that in the link inserted the key and the value

so it will work, but not as much as you need
<!-- Widgets -->
<?php foreach($informers as $informer): ?>
 <div class="info">
<h3><?=$informer[0]?></h3>

 <?php $link_type = $informer['sub']; ?>>
 <p>- <a href="<?=PATH?>informer/"></a></p>
 <?= $link_type; ?>
 </div> 
<?php endforeach; ?>
 <!-- Widgets -->
- Gus.Murray commented on March 19th 20 at 10:07
@Gus.Murray, sub is an array https://vk.cc/9ebKUI - alf.Bashirian commented on March 19th 20 at 10:10
@Gus.Murray, nope not working - alf.Bashirian commented on March 19th 20 at 10:13
@alf.Bashirian, Yes, that's

informer function(){
 $query = "SELECT * FROM links
 INNER JOIN informers ON
 links.parent_informer = informers.informer_id
 ORDER BY informer_position, links_position";
 $res = mysql_query($query) or die(mysql_query());

 $informers = array();
 $name = "; // a flag named widget
 while($row = mysql_fetch_assoc($res)){
 if($row['informer_name'] != $name){ // if this widget in the array yet
 $informers[$row['informer_id']][] = $row['informer_name'];
 $informers[$row['informer_id']][] = $row['informer_id'];

 $name = $row['informer_name'];
}
 $informers[$row['parent_informer']]['sub'][$row['link_id']] = $row['link_name'];
 $informers[$row['parent_informer']]['sub'][$row['link_id']] = $row['link_type'];
 // $informers[$row['parent_informer']]['link_type'] = $row['link_type'];
 // put the page in a widget
}
 return $informers;
}

I can't do it my eyes closed to do something) - Gus.Murray commented on March 19th 20 at 10:16
@Gus.Murray, I'm sorry that you are so tormented (
Now it works BUT only the subcategory name prala https://vk.cc/9ec2UI - alf.Bashirian commented on March 19th 20 at 10:19
If that can throw you a couple of hundred to me.d. - alf.Bashirian commented on March 19th 20 at 10:22

Find more questions by tags MySQLPHP