Jump to content
php.lv forumi

IF there already is?


sandis_m

Recommended Posts

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

Link to comment
Share on other sites

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
}

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...