我在数据库中有两个表1.发布和2.操作系统
post:
+----+------------+-------+-------+-----+--------+------+-----+-------+
| id | title | metaD | metaK | img | author | date | cat | text |
+----+------------+-------+-------+-----+--------+------+-----+-------+
| 1 | some title | data | data |data | data | data | app | data |
| 2 | title2 | data | data |data | data | data | os | data |
| 3 | title3 | data | data |data | data | data | oth | data |
+----+------------+-------+-------+-----+--------+------+-----+-------+
os:
+------+----------+----------+--------+--------+--------+--------+-------+-------+------+------+--------+
| osId | ostitle | osimg | oscpuM | oscpuR | osramM | osramR | oshdM | oshdR | osgM | osgR | osdown |
+----+------------+----------+-----------------+--------+--------+-------+-------+------+------+--------+
| 1 | title8 | name | here comes text | data | data | data | data | data | data | data |
| 2 | title2 | name | here comes text | data | data | data | data | data | data | data |
| 3 | title4 | name | here comes text | data | data | data | data | data | data | data |
+----+------------+----------+-----------------+--------+--------+-------+-------+------+------+--------+
和代码:
//get data from "post"
$post = "SELECT * FROM post WHERE id='{$_GET['id']}'";
$post1 = mysql_query($post);
$postV = mysql_fetch_array($post1);
$postID = $postV['id'];
$postTitle = $postV['title'];
$postD = $postV['metaD'];
$postK = $postV['metaK'];
$postImg = $postV['img'];
$postAuthor = $postV['author'];
$postDate = $postV['date'];
$postCat = $postV['cat'];
$postText = $postV['text'];
//get data from "os"
$os = "SELECT * FROM os WHERE ostitle='{$_GET['ostitle']}'";
$os1 = mysql_query($os);
$osV = mysql_fetch_array($os1);
$osID = $osV['osId'];
$osTitle = $osV['ostitle'];
$osImg = $osV['osimg'];
$osCpuM = $osV['oscpuM'];
$osCpuR = $osV['oscpuR'];
$osRamM = $osV['osramM'];
$osRamR = $osV['osramR'];
$osHdM = $osV['oshdM'];
$osHdR = $osV['oshdR'];
$osGM = $osV['osgM'];
$osGR = $osV['osgR'];
$osDown = $osV['osdown'];
//dispaly post
<?php
echo "<img class='view_newsimg' src='$postImg'>
<h3 class='lath'>$postTitle</h3>
<ul class='det'>
<li class='adc'>avtori: $postAuthor</li>
<li class='adc'>TariRi: $postDate</li>
<li class='adc'>kategoria: $postCat</li>
</ul>
<p class='news'>
$postText";
//display from "os"
$osif = $postV['cat'];
if ($osif == 'os')
{
echo "<div class='os1'>
<div>1</div>
<div class='os1_1'>procesori</div>
<div class='os1_1'>operatiuli mexsiereba</div>
<div class='os1_1'>adgili myar diskze</div>
<div class='os1_1'>grafikuli baraTi</div>
</div>
<div class='os1'>
<div>minimaluri</div>
<div>$osCpuM</div>
<div>$osRamM</div>
<div>$osHdM</div>
<div>$osGM</div>
</div>
<div class='os1'>
<div>rekomendebuli</div>
<div>$osCpuR</div>
<div>$osRamR</div>
<div>$osHdR</div>
<div>$osGR</div>
</div>";
}
?>
此页面的网址是:“。com / view.php?id = 2ostitle = title2” 但我有这个错误:“注意:第54行的D:\ XAMPP \ htdocs \ LinuxOid.com \ blocks \ db3.php中的未定义索引:ostitle”(这是:$ os =“SELECT * FROM os WHERE ostitle ='{ $ _GET ['ostitle']}'';;)
我怎么能解决这个问题?
答案 0 :(得分:1)
你想念&amp;在网址中更改此行
.com/view.php?id=2ostitle=title2
要
.com/view.php?id=2&ostitle=title2
编辑:使用此代码
<?php
//get data from "post"
$post = "SELECT * FROM post WHERE id='{$_GET['id']}'";
$post1 = mysql_query($post);
$postV = mysql_fetch_array($post1);
$postID = $postV['id'];
$postTitle = $postV['title'];
$postD = $postV['metaD'];
$postK = $postV['metaK'];
$postImg = $postV['img'];
$postAuthor = $postV['author'];
$postDate = $postV['date'];
$postCat = $postV['cat'];
$postText = $postV['text'];
//get data from "os"
$os = "SELECT * FROM os WHERE ostitle='{$_GET['ostitle']}'";
$os1 = mysql_query($os);
$osV = mysql_fetch_array($os1);
$osID = $osV['osId'];
$osTitle = $osV['ostitle'];
$osImg = $osV['osimg'];
$osCpuM = $osV['oscpuM'];
$osCpuR = $osV['oscpuR'];
$osRamM = $osV['osramM'];
$osRamR = $osV['osramR'];
$osHdM = $osV['oshdM'];
$osHdR = $osV['oshdR'];
$osGM = $osV['osgM'];
$osGR = $osV['osgR'];
$osDown = $osV['osdown'];
//dispaly post
echo "<img class='view_newsimg' src='{$postImg}'>
<h3 class='lath'>{$postTitle}</h3>
<ul class='det'>
<li class='adc'>avtori: {$postAuthor}</li>
<li class='adc'>TariRi: {$postDate}</li>
<li class='adc'>kategoria: {$postCat}</li>
</ul>
<p class='news'>{$postText}";
//display from "os"
$osif = $postV['cat'];
if ($osif == 'os')
{
echo "<div class='os1'>
<div>1</div>
<div class='os1_1'>procesori</div>
<div class='os1_1'>operatiuli mexsiereba</div>
<div class='os1_1'>adgili myar diskze</div>
<div class='os1_1'>grafikuli baraTi</div>
</div>
<div class='os1'>
<div>minimaluri</div>
<div>{$osCpuM}</div>
<div>{$osRamM}</div>
<div>{$osHdM}</div>
<div>{$osGM}</div>
</div>
<div class='os1'>
<div>rekomendebuli</div>
<div>{$osCpuR}</div>
<div>{$osRamR}</div>
<div>{$osHdR}</div>
<div>{$osGR}</div>
</div>";
}
?>
答案 1 :(得分:0)
网址存在一些问题。它应该像
COM / view.php ID = 2及?ostitle = TITLE2