Гном
Новичок
Не могу выбрать правильно с базы
Есть 2 две таблицы
teachers
Поле Тип Ноль По умолчанию
id int(11) Нет
name varchar(50) Да NULL
photo text Нет
info text Нет
add text Нет
path text Нет
count int(11) Нет 0
и teach_own
Поле Тип Ноль По умолчанию
id int(255) Нет
name text Нет
add text Нет
path text Нет
count int(11) Нет 0
Надо вывести данные name из teachers и при нажатии на данные чтоб открывалась информация с teach_own как перекрестить ссылку и две таблицы и сделать праввильную выборку??? уже 5 дней все пытаюсь никак не додумаюсь ПОМОГИТЕ!!!!
Есть 2 две таблицы
teachers
Поле Тип Ноль По умолчанию
id int(11) Нет
name varchar(50) Да NULL
photo text Нет
info text Нет
add text Нет
path text Нет
count int(11) Нет 0
и teach_own
Поле Тип Ноль По умолчанию
id int(255) Нет
name text Нет
add text Нет
path text Нет
count int(11) Нет 0
Надо вывести данные name из teachers и при нажатии на данные чтоб открывалась информация с teach_own как перекрестить ссылку и две таблицы и сделать праввильную выборку??? уже 5 дней все пытаюсь никак не додумаюсь ПОМОГИТЕ!!!!
PHP:
<?php
include "kaf/config.php";
$uploadToPath="/site/portal/www/own/teach";
$attachmentUrl = 'http://portal/own/teach/';
$query="select * from teachers order by id";
$ath=mysql_query($query);
if ($ath)
{
while ($teach=mysql_fetch_array($ath))
{
If ($teach['photo']!=""){
echo "<table><td width=20% height=100%><div align=left>
<img src='".$teach['photo']."' width=100 height=100></div>";
echo "<br><td width=80%><b>".$teach['name']." </b><br>";
echo "";
echo $teach['info'];
echo "</table>";}
else {
echo "<table><td width=20% height=100%><div align=left></div>";
echo "<br><td width=80%><a href=?id=$teach[id]><b>".$teach['name']."</a> </b><br>";
echo "";
echo $teach['info'];
echo "</table>";
}
}
}
if ($id!=0) {
$attachmentUrl="http://portal/own/teach/";
$tr=mysql_query("select name from teachers where id=$id");
$userResult = mysql_query("SELECT * from teach_own where name='$tr'");
while ($userResultArray = mysql_fetch_array($userResult)){
?>
<tr>
<td><b><?php echo $userResultArray["add"]; ?> </b>
</tr>
<?php if(!empty($userResultArray["path"])) { ?>
<tr>
<td><span class="attachment">Ôàéë:</span> <a href="<?php echo "$attachmentUrl" . $userResultArray["path"]; ?>" class="link"><?php echo $userResultArray["path"]; ?></a><br>
<br></td>
</tr> <br>
<?
}
}
}