Tabela uzytkownicy wygląda tak:
Cytat
id | name | password | date_join | grupa | posts
Mam nadzieję, że mnie zrozumieliście. Pozdrawiam.
$sql = mysql_query("SELECT id FROM tabela_z_postami WHERE id_user = '".$jakis_user."' "); //zamisat id_user możesz dać co innego w zależności jak masz kod
<?php include ('baza.php'); include ('functions.php'); $id = $_GET['id']; switch($_GET['value']) { case 'save': $edit_temat = $_POST['edit_temat']; $edit_opis = $_POST['edit_opis']; $edit_post_reply = $_POST['edit_post_reply']; break; case 'add': $idt = $wiersz['id']; $autor_reply = $_SESSION['login']; $reply = $_POST['post_reply']; $odp = mysql_query("INSERT INTO odpowiedzi (id_thread, date_reply, autor_reply, post_reply) VALUES ('$id', now(), '$autor_reply', '$reply')"); $log_user = $_SESSION['login']; $post_user = mysql_fetch_array(mysql_query("SELECT `posts` FROM `uzytkownicy` WHERE `name` = '$log_user'")); $post_user = $post_user[0]; $post_user++; echo ("Poprawnie dodałeś wiadomość!<br /><a href=\"index.php?action=thread&id=$id\">Przejdź do tematu</a>"); break; default; { switch($_GET['option']) { case 'edit-thread': echo ('<form action="index.php?action=thread&id='.$id.'&option=edit-thread&value=save" method="POST"> <table border="0" width="100%"> <tr> <td valign="top" width="12%">Temat:</td> <td width="88%"><input type="text" name="edit_temat" size="60" value="'.$wiersz['temat'].'"></td> </tr> <tr> <td>Opis tematu:</td> <td><input type="text" name="edit_opis" size="60" value="'.$wiersz['opis'].'"></td> </tr> <tr> <td colspan="2"><textarea name="edit_post_reply" cols="60" rows="10">'.$wiersz['post'].'</textarea></td> </tr> </table><br /> <input type="submit" value="Zapisz"> </form>'); break; case 'reply': showPostReplyForm(); break; default; $autor_posta_reply = $wiersz['autor']; $poster = $wiersz['autor']; { $user_name = "Mistrzu"; ?> <table border="0" width="100%" cellspacing="1"> <tr> <td colspan="3" width="100%" style="border: 1px solid #000; background-color: #5684ae; padding: 5px; height: 40px;"><a href="index.php">Index</a> > <?php echo $wiersz['temat']; ?></td> </tr> <tr style="background-color: #cfe2ff;"> <div style="text-align: right;"><a href="index.php?action=thread&id=<?php echo $wiersz['id']; ?>&option=edit-thread">Edytuj</a></td> </tr> <tr style="background-color: #5684ae; padding: 5px; height: 13px;"> <td colspan="2">Post: #ID</td> </tr> <tr><td></td></tr> <?php { <tr><td colspan="2" style="background-color: #5684ae">Odpowiedź na: '.$wiersz['temat'].' | '.$odpw['date_reply'].'</td></tr> <tr style="background-color: #cfe2ff;"> <td width="20%" valign="top"><a href="index.php?action=showprofile&name='.$odpw['autor_reply'].'">'.$odpw['autor_reply'].'</a><br /><br />Posty: '.$user_info['posts'].'<br />Dołączył: '.$user_info['date_join'].'</td> </tr> <tr style="background-color: #5684ae; padding: 5px; height: 13px;"> <td colspan="2">Post: #ID '.$odpw['id_thread'].'</td> </tr> <tr><td></td></tr> '); } ?> </table> <?php } showPostReplyForm(); } } } ?>
$user_name = "Mistrzu";
$user_name = "Mistrzu";
<?php { <tr><td colspan="2" style="background-color: #5684ae">Odpowiedź na: '.$wiersz['temat'].' | '.$odpw['date_reply'].'</td></tr> <tr style="background-color: #cfe2ff;"> <td width="20%" valign="top"><a href="index.php?action=showprofile&name='.$odpw['autor_reply'].'">'.$odpw['autor_reply'].'</a><br /><br />Posty: '.$user_info['posts'].'<br />Dołączył: '.['date_join'].'</td> </tr> <tr style="background-color: #5684ae; padding: 5px; height: 13px;"> <td colspan="2">Post: #ID '.$odpw['id_thread'].'</td> </tr> <tr><td></td></tr> '); } ?>
$odp_autor_reply = mysql_query("SELECT id FROM tabela_z_postami WHERE user = '".$odpw['autor_reply']."' ");
<?php include ('baza.php'); include ('functions.php'); $id = $_GET['id']; switch($_GET['value']) { case 'save': $edit_temat = $_POST['edit_temat']; $edit_opis = $_POST['edit_opis']; $edit_post_reply = $_POST['edit_post_reply']; mysql_query("UPDATE `tematy` SET `temat` = '$edit_temat', `opis` = '$edit_opis', `post` = '$edit_post_reply' WHERE `id` = '$id'"); break; case 'add': $idt = $wiersz['id']; $autor_reply = $_SESSION['login']; $reply = $_POST['post_reply']; $odp = mysql_query("INSERT INTO odpowiedzi (id_thread, date_reply, autor_reply, post_reply) VALUES ('$id', now(), '$autor_reply', '$reply')"); $log_user = $_SESSION['login']; $post_user = mysql_fetch_array(mysql_query("SELECT `posts` FROM `uzytkownicy` WHERE `name` = '$log_user'")); $post_user = $post_user[0]; $post_user++; mysql_query("INSERT INTO `tematy` (id, autor, date_thread, temat, opis, post) VALUES ('', now(), 'temat', 'opis', 'post' )"); echo ("Poprawnie dodałeś wiadomość!<br /><a href=\"index.php?action=thread&id=$id\">Przejdź do tematu</a>"); break; default; { switch($_GET['option']) { case 'edit-thread': echo ('<form action="index.php?action=thread&id='.$id.'&option=edit-thread&value=save" method="POST"> <table border="0" width="100%"> <tr> <td valign="top" width="12%">Temat:</td> <td width="88%"><input type="text" name="edit_temat" size="60" value="'.$wiersz['temat'].'"></td> </tr> <tr> <td>Opis tematu:</td> <td><input type="text" name="edit_opis" size="60" value="'.$wiersz['opis'].'"></td> </tr> <tr> <td colspan="2"><textarea name="edit_post_reply" cols="60" rows="10">'.$wiersz['post'].'</textarea></td> </tr> </table><br /> <input type="submit" value="Zapisz"> </form>'); break; case 'reply': showPostReplyForm(); break; default; $autor_posta_reply = $wiersz['autor']; $poster = $wiersz['autor']; { ?> <table border="0" width="100%" cellspacing="1"> <tr> <td colspan="3" width="100%" style="border: 1px solid #000; background-color: #5684ae; padding: 5px; height: 40px;"><a href="index.php">Index</a> > <?php echo $wiersz['temat']; ?></td> </tr> <tr style="background-color: #cfe2ff;"> <div style="text-align: right; padding-right: 10px;"><?php if ($_SESSION['login']==$wiersz['autor']) { ?><a href="index.php?action=thread&id=<?php echo $wiersz['id']; ?>&option=edit-thread">Edytuj</a><?php } ?></td> </tr> <tr style="background-color: #5684ae; padding: 5px; height: 13px;"> <td colspan="2">Post: #ID</td> </tr> <tr><td></td></tr> <?php { $odp_autor_reply = mysql_query("SELECT id FROM `uzytkownicy` WHERE `name` = '".$odpw['autor_reply']."' "); <tr><td colspan="2" style="background-color: #5684ae">Odpowiedź na: '.$wiersz['temat'].' | '.$odpw['date_reply'].'</td></tr> <tr style="background-color: #cfe2ff;"> <td width="20%" valign="top"><a href="index.php?action=showprofile&name='.$odpw['autor_reply'].'">'.$odpw['autor_reply'].'</a><br /><br />Posty: '.$user_info['posts'].'<br />Dołączył: '.$user_info['date_join'].'</td> </tr> <tr style="background-color: #5684ae; padding: 5px; height: 13px;"> <td colspan="2">Post: #ID '.$odpw['id_thread'].'</td> </tr> <tr><td></td></tr> '); } ?> </table> <?php } showPostReplyForm(); } } } ?>
<?php <tr><td colspan="2" style="background-color: #5684ae">Odpowiedź na: '.$wiersz['temat'].' | '.$odpw['date_reply'].'</td></tr> <tr style="background-color: #cfe2ff;"> <td width="20%" valign="top"><a href="index.php?action=showprofile&name='.$odpw['autor_reply'].'">'.$odpw['autor_reply'].'</a><br /><br />Posty: '.$user_info['posts'].'<br />Dołączył: '.$user_info['date_join'].'</td> </tr> <tr style="background-color: #5684ae; padding: 5px; height: 13px;"> <td colspan="2">Post: #ID '.$odpw['id_thread'].'</td> </tr> <tr><td></td></tr> '); } ?>
<?php include ('baza.php'); include ('functions.php'); $id = $_GET['id']; //$autor_posta_reply = $wiersz['autor']; //to tez nie wiem po co, zawsze można użyć odwołania do $wiersz['autor'] //$poster = $wiersz['autor']; //to tez nie wiem po co, zawsze można użyć odwołania do $wiersz['autor'] //pobieranie danych na temat autora postu //tu nie musisz wrzucać tego w pętle while gdyż i tak wybierze ci 1 pozycje, chyba że dopuszczasz możliwość 2 autorów o tym samej nazwie $ile_postow2 = mysql_query("SELECT * FROM odpowiedzi WHERE autor_reply = '".$user_wierszDane['name']."' "); ?> <table border="0" width="100%" cellspacing="1"> <tr> <td colspan="3" width="100%" style="border: 1px solid #000; background-color: #5684ae; padding: 5px; height: 40px;"><a href="index.php">Index</a> > <?php echo $wiersz['temat']; ?></td> </tr> <tr style="background-color: #cfe2ff;"> <div style="text-align: right;"><a href="index.php?action=thread&id=<?php echo $wiersz['id']; ?>&option=edit-thread">Edytuj</a></td> </tr> <tr style="background-color: #5684ae; padding: 5px; height: 13px;"> <td colspan="2">Post: #ID</td> </tr> <tr><td></td></tr> <?php //odpowiedzi $ile_postow2 = mysql_query("SELECT * FROM odpowiedzi WHERE autor_reply = '".$user_odpDane['name']."' "); echo '<tr><td colspan="2" style="background-color: #5684ae">Odpowiedź na: '.$wiersz['temat'].' | '.$odpw['date_reply'].'</td></tr> <tr style="background-color: #cfe2ff;"> <td width="20%" valign="top"><a href="index.php?action=showprofile&name='.$user_odpDane['name'].'">'.$user_odpDane['name'].'</a><br /><br />Posty: '.$suma_postow.'<br />Dołączył: '.$user_odpDane['date_join'].'</td> </tr> <tr style="background-color: #5684ae; padding: 5px; height: 13px;"> <td colspan="2">Post: #ID '.$odpw['id_thread'].'</td> </tr> <tr><td></td></tr> '; } ?> </table> <?php showPostReplyForm(); } ?>