BluwAngel Posted March 4, 2012 Share Posted March 4, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/258271-query-from-2-tables/ Share on other sites More sharing options...
creata.physics Posted March 4, 2012 Share Posted March 4, 2012 Well, can you at least try to build a join query and post it here? You've shown me what you need but you haven't shown me what you've done to try to accomplish your goal. So far it only seems like you just want somebody to build your code for you. Quote Link to comment https://forums.phpfreaks.com/topic/258271-query-from-2-tables/#findComment-1323903 Share on other sites More sharing options...
BluwAngel Posted March 4, 2012 Author Share Posted March 4, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/258271-query-from-2-tables/#findComment-1323913 Share on other sites More sharing options...
BluwAngel Posted March 5, 2012 Author Share Posted March 5, 2012 here are screenshots from tables and joinend 2 tables (ZAMJENA and EVENTS) Quote Link to comment https://forums.phpfreaks.com/topic/258271-query-from-2-tables/#findComment-1323935 Share on other sites More sharing options...
BluwAngel Posted March 5, 2012 Author Share Posted March 5, 2012 nwm triple while loop and some new querys works Quote Link to comment https://forums.phpfreaks.com/topic/258271-query-from-2-tables/#findComment-1324076 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.