Jump to content
php.lv forumi

Forumi


false

Recommended Posts

Tatad dātubāze `foruma_nosaukumi` izskatas šadi

`id` int(11) NOT NULL AUTO_INCREMENT,

`nos` varchar(255) COLLATE utf8_unicode_ci NOT NULL,

PRIMARY KEY (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=11 ;

Dātubāze `forumi` izskatas šadi

`id` int(11) NOT NULL AUTO_INCREMENT,

`nosaukums` varchar(255) COLLATE utf8_unicode_ci NOT NULL,

`paskaidrojums` varchar(255) COLLATE utf8_unicode_ci NOT NULL,

`f_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,

PRIMARY KEY (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=11 ;

 

Kāds var palīdzet parveidot kodu lai katrs forums stāvetu zem konkrēta nosaukuma id.

 

Pats kods

<div id="forums">
<?php
$select_f = mysql_query("SELECT * FROM foruma_nosaukumi") or die(mysql_error());
while($f = mysql_fetch_array($select_f)){
$select_ff = mysql_query("SELECT * FROM forumi WHERE f_id = '".$f['id']."'") or die(mysql_error());
while($ff = mysql_fetch_array($select_ff)){
?>
<div class="border"><div class="title">
<?php echo $f['nos']; ?></div><table class="ipbtable" cellspacing="1">
<tbody><tr> 
<td class="head" width="66%">Forumi</td>
<td class="head" style="text-align: center;" width="7%">Temati</td>
<td class="head" style="text-align: center;" width="7%">Atbildes</td>
<td class="head" width="35%">Pēdējā tēma</td></tr>		
<tr style="border-bottom: 1px solid rgb(255, 255, 255);"> 
<td class="row2">
<b><a href="/forum/?id=<?php echo $ff['id']; ?>"><?php echo $ff['nosaukums']; ?></a></b><br>
<span style="color: rgb(102, 102, 102); font-size: 10px; font-family: tahoma;"><?php echo $ff['paskaidrojums']; ?></span>
</td>
<td class="row1" style="border-left: 1px solid rgb(255, 255, 255);" align="center">1</td>
<td class="row1" style="border-left: 1px solid rgb(255, 255, 255);" align="center">2</td>
<td class="row1" style="border-left: 1px solid rgb(255, 255, 255); height: 50px;" nowrap="nowrap">
Tēma: <b><a href="">adsadsasd</a></b><br/><small>Atbildes <b>42</b> Autors <b>false</b></small></td></tr></table></div><br>
<?php
}}
?>
<br></div>

Problēma ir tāda kā viņš izvēlk foruma nosaukumus un zem katra nosaukuma liek pa vienam forumam, pat ja tā id nesakrīt.

Piemēram db `forumi` ir šadi ieraksti

id, `nosaukums`, `paskaidrojums`, `f_id`

1, 'test', 'tralallala', '1'

2, 'test2', 'tralallala2', '2'

3, 'test3', 'tralallala3', '1'

 

Viņš to test ieliek zem foruma nosaukuma ar id 1, test2 zem id 2, test3 zem id 3

Edited by false
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...