Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
bTemplate problem oko mysql-a

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
unLog!c



Joined: 27 May 2004
Posts: 185
Location: Osijek

PostPosted: 20.07.2007 17:02    Post subject: bTemplate problem oko mysql-a Add user to your forum ignore list Reply with quote

Počeo sam koristiti taj template engine i sve radi super, no naišao sam na nešto što me već pomalo počinje nervirati...

Dakle, nije problem izvuči podatke iz jedne mysql baze putem mysql_fetch_assoc ili mysql_fetch_array... Već je problem kada u jednoj bazi imam podatak koji je recimo ID nekoga retka iz neke druge baze i onda u istoj petlji pokušam izvuči te podatke isto kroz pelju...

Dogodi se to da kada ispisujem template on ljepo ispiše podatke koji su izvučeni u prvoj petlji, ali ne ispiše i one koji su izvučeni i u petlji unutar ove Confused

Znam da sam to malo glupavo objasnio, ali evo kôda:

korisnici.php =>
Code:
         default:
            $query = mysql_query("SELECT * FROM cms_x_userprivilegies") or die (mysql_error());
            while ($row = mysql_fetch_assoc($query)){
               $users[] = $row;
               $uid = $row['uid'];
               $query_username = mysql_query("SELECT * FROM cms_users WHERE user_id = '$uid'") or die (mysql_error());
               while ($row_username =mysql_fetch_assoc($query_username)){
                  $uname[] = $row_username;
               }
            }

            $tpl->set('users', $users);
            $tpl->set('uname', $uname);

            $tpl->set('content', $tpl->fetch($path_php . 'adm/tpl/korisnici.tpl'));
            echo $tpl->fetch($path_php . 'adm/tpl/main_content.tpl');
            break;


korisnici.tpl =>
Code:
<center>
<table width="350px">
   <tr>
      <td width="150px" class="under"><p>Korisničko ime:</p></td>
      <td width="200px" class="under"><p>Status:</p></td>
   </tr>
   <loop:users>
   <tr>
      <td width="150px" class="under"><a href="<tag:url />korisnik/profil/<tag:users[].uid />" title="<tag:uname[].username />"><tag:uname[].username /></a></td>
      <td width="200px" class="under">
         <form name="user change status" method="post"  action="<tag:url />adm/index.php/korisnici/add/<tag:users[].id />">
               <select>
                  <option value="<tag:users[].status />"><tag:users[].status /></option>
                  <option value="0">0 - Nema statusa</option>
                  <option value="1">1 - Blog Moderator</option>
                  <option value="2">2 - Blog, kolumne moderator</option>
                  <option value="3">3 - Super moderator</option>
                  <option value="4">4 - Admin</option>
                  <option value="5">5 - Super Admin</option>
               </select>
               <input type="Submit" name="submit" value="Submit">
            </form>
      </td>
   </tr>
   </loop:users>
</table>
</center>



nadam se da će mi netko uspjeti pomoći prije neg pojedem tipkovnicu i miša od bjesa Confused

_________________
Why dont you go out and play hide and go fuck your self like all other NORMAL kids?
Back to top
View user's profile Send private message MSN Messenger
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 20.07.2007 18:14    Post subject: Add user to your forum ignore list Reply with quote

Napravi join (mysql pretpostavljam, nabrzaka):
Code:
SELECT * FROM cms_x_userprivilegies up, cms_users u WHERE up.uid = u.user_id

S tim da imaj na umu da ti je bolje selectati samo kolone koje trebas, a ne razbacivati se
zvjezdicama okolo, mada ce te to ujest tek na ogromnim siteovima.
I pretpostavka je da su ti primarni kljucevi i indexi dobri na tim tablicama, pa join ne bi
trebao biti problem.

Ovo gore ti u jednom kveriju vraca sve kolone iz obadve tablice, za svaki row za koji
postoji match prema where uvjetu.

_________________
[+]I[+]am[+]my[+]own[+]religion[+]
Back to top
View user's profile Send private message Visit poster's website Twitter profile
unLog!c



Joined: 27 May 2004
Posts: 185
Location: Osijek

PostPosted: 20.07.2007 23:09    Post subject: Add user to your forum ignore list Reply with quote

Aha, fora stvar... erm, ima li neko lako štivo na temu toga (joinanja mysql querya) ?

_________________
Why dont you go out and play hide and go fuck your self like all other NORMAL kids?
Back to top
View user's profile Send private message MSN Messenger
carr



Joined: 13 Nov 2003
Posts: 1397
Location: Karlovac

PostPosted: 20.07.2007 23:19    Post subject: Add user to your forum ignore list Reply with quote

unLog!c wrote:
Aha, fora stvar... erm, ima li neko lako štivo na temu toga (joinanja mysql querya) ?

google -> "sql join"

http://www.w3schools.com/sql/sql_join.asp

ovo sto zyt je napravio je neki inner join kao...

_________________
Bolje biti malo lud, nego malo pametan.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group