В БД две таблицы связаны между собой. таблицы имеют стр-ру:
таблица contents:
Id page categories_id title meta_d meta_k date_d discription text_s
таблица categories: Id Name id_vid
связаны через: categories_id и Id
мне нужно вывести на страницу информацию из первой таблицы, что вполне работает, а из второй нужно подставить строку из поля Name вместо categories_id, что собственно и не получается. Причем вообще не выводится ни Id ни Name
CODE ( htmlphp):
скопировать код в буфер обмена
<?php $db = mysql_connect("localhost","admin","3326624") or die("не удалось подключиться к серверу"); $sql = "SELECT contents.id, page, categories_id, title, meta_d, meta_k, DATE_FORMAT(date_d,'%d.%m.%Y') AS date, discription, categories.id, categories.name FROM contents, categories WHERE categories_id='$_GET[categories_id]' and contents.categories_id=categories.id ORDER BY date_d DESC"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1251" /> <title><?php echo $myrow["page"]?></title> <meta name="keywords" content="<?php echo $myrow["meta_k"]?>" /> <meta name="description" content="<?php echo $myrow["meta_d"]?>" /> <link rel="stylesheet" href="style/style.css" type="text/css" media="screen, projection" /> <link rel="stylesheet" type="text/css" href="style/stylemenu.css" /> <link rel="stylesheet" type="text/css" href="style/styletopmenu.css" /> <link rel="stylesheet" type="text/css" href="style/stylegalery.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="top_menu"><?php include"blocks/top_menu.php";?></div> <div id="login"></div> <div id="galery"><?php include"blocks/gal_menu.php";?></div> <div id="find"><?php include"blocks/form_search.php";?></div> </div><!-- #header--> <div id="middle"> <div id="container"> <div id="main_menu"> <?php include"blocks/main_menu.php";?> </div> <div id="title"> <h1>Content</h1> </div> <div id="bgcontent"> <div id="content"> <?php do { printf("<table align='center' class='news'> <tr> <td class='news_title' colspan='2'><a href='view_stati.php?id=%s'><h2>%s</h2></a></td><td></td> </tr> <tr> <td class='news_date'>%s</td><td class='news' align='right'>Категория: %s</td> </tr> <tr> <td colspan='2'>%s</td><td></td> </tr> <tr> <td class='news_footer' colspan='2' style='font-style:italic; font-weight:500' align='right'><a href='view_stati.php?id=%s'>Подробнее...</a></td><td></td> </tr> </table><br>",$myrow["id"],$myrow["title"],$myrow["date"],$myrow["categories.name"],$myrow["discription"],$myrow["id"]); } ?> </div><!-- #content--> <div id="contfootbg"> </div><!-- #contfootbg--> </div><!-- #bgcontent--> </div><!-- #container--> <div class="sidebar" id="sideRight"> <?php include"blocks/sb_soveti.php";?> </div><!-- .sidebar#sideRight --> </div><!-- #middle--> </div><!-- #wrapper --> <div id="footer"> </div><!-- #footer --> </body> </html>
(Добавление)
вопрос снять, проблема решена
|