Jump to content

query from 2 tables


BluwAngel

Recommended Posts

this is the problem i have 2 tables

 

table named ZAMJENE with fields id_event_1, id_event_2

table named EVENTS with fields  id_event and event_date

 

and i need echo

 

$id_event_1 on date(EXTRACT FROM TABLE EVENTS FIELD event_date) can be replaced with $id_event_2 on date(EXTRACT FROM TABLE EVENTS FIELD event_date)

 

structure must remains because i have half site build already and i have 3rd table where i just need use JOIN

 

hope you understand problem

Link to comment
Share on other sites

tried that before... for example in table ZAMJENA i have 1 rown and on EVENTS have 20 rows

he fills data under id_event_1 and id_event_2 randomly (and i cant afford that)

 

so far code is this

<?php
session_start();
include "check.php";
include "db_connect.php";

//spojit na tablicu pogledat da li postoje termini za zamjenu
$moj_id	= $_SESSION['id'];
$query_zamjene = mysql_query ("SELECT * FROM zamjene JOIN users ON id_user_2=id WHERE id_user_1='$moj_id'");
//broj zamjena
$br_zamjena		= mysql_num_rows($query_zamjene);

if ($br_zamjena >0){
echo "Imate $br_zamjena mogućih zamjena
<ul>";

while($rows = mysql_fetch_array($query_zamjene))
{
$id_zamjena		= $rows['id_zamjena'];
$id_event_1		= $rows['id_event_1'];
$id_event_2		= $rows['id_event_2'];
$id_user_2		= $rows['id_user_2'];
$ime_2			= $rows['ime'];
$prezime_2		= $rows['prezime'];


echo "<li>Vaš event $id_event_1 zamjenite sa $id_event_2, zamjenu je tražio $ime_2 $prezime_2 </li>";
//english  your event $id_event_1 can be changed with $id_event_2, requested by $ime_2 $prezime_2


}

}
else echo "Nemate zahtjeva za zamjenu"; // no requests for change

?>

 

here i work with 3 tables EVENTS ZAMJENE USER i mange to get name from USER table but i dont know that part with event

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.