sandis_m Posted December 6, 2009 Report Share Posted December 6, 2009 TABLE friends myid friendid 1 44 1 6 44 1 -------------- $friendid = $_POST['friendid']; $esesmu = $_SESSION['user_id']; // Connection mysql_connect("mysql.izabiza.net", "table_333", "rootpwd") or die(mysql_error()); mysql_select_db("table_333") or die(mysql_error()); // Inser mysql_query ("INSERT INTO friends (myid, friendid) VALUES ('$esesmu', '$friendid')"); header("Location:http://localhost/friends/?id=$friendid"); Kaa izdariit taa, lai - ja tabulaa friends pie mana id nav lietotaja id, kura profilu pashlaik skatos, paraada: <form action="index.php" method="POST"> <input type="hidden" value="<?php $friendid ?>" <input type="submit" value="draudzeties"> </form> Un otraadaak - ja tabulaa friends pie mana id ir jau lietotaaja id , kura profilu tagad skatos, paraada: <a href="stop-frienshipu.php">Nedraudzeeties</a> ... esmu strupceljaa :D Quote Link to comment Share on other sites More sharing options...
2easy Posted December 6, 2009 Report Share Posted December 6, 2009 un kas tieši iedzina strupceļā? 1) paņemt datus no tabulas ar sql SELECT? 2) pieņemt lēmumu ar if else un izdrukāt vienu vai otru html ar echo? Quote Link to comment Share on other sites More sharing options...
sandis_m Posted December 6, 2009 Author Report Share Posted December 6, 2009 un kas tieši iedzina strupceļā? 1) paņemt datus no tabulas ar sql SELECT? 2) pieņemt lēmumu ar if else un izdrukāt vienu vai otru html ar echo? nav nemaz tik vienkaarshi Quote Link to comment Share on other sites More sharing options...
renathy Posted December 6, 2009 Report Share Posted December 6, 2009 Nu dari kkā tā: 1) kā jau teica - izveido SELECTu, kas pārbauda "tabulaa friends pie mana id nav lietotaja id, kura profilu pashlaik skatos" $q = 'select * from friends where drauga_id = $friendid and es_id = $esesmu'; $result = mysql_query($q); $cnt = mysql_row_num($result); 2)pieņem lēmumu if ($cnt == 1) { // tabula nav datu par manu draudzibu ar draugu } else { // ir dati } Quote Link to comment Share on other sites More sharing options...
2easy Posted December 6, 2009 Report Share Posted December 6, 2009 oo, renathy gan ir izpalīdzīgāka hehe who_i_am, jau meitenes sāk tevi barot ar karotīti :D:D:D starp citu, maza kļūdiņa: tieši tā, bet otrādāk ;) if ($cnt == 1) ... // ir dati else ... // nav dati Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.