Tuesday, 15 May 2012

php - Select my sql database doesnt work -


I just wanted to create a WALL POST where I only 'feeds' with my friends but this is 'feedid' Do not order ... what should i do ??

  & lt ;? Php $ user = $ _SESSION ['username']; $ 12 = mysql_query ("WHERE username" = '$ user' "by select friends); If (mysql_num_rows ($ 12)! = 0) {$ from = mysql_query ("Choose * Friends WHERE user name = '$ user'"); While ($ row2 = mysql_fetch_object (from $)) {$ from1 = $ row2- & gt; friend; $ Files = globe ('lang /'. $ Lang '.xml'); Foreign currency (files as $ $ file) {$ ergebnis = mysql_query ("Select feed from WHERE user name = '$ from1' ORDER by feedID DESC"); While ($ row = mysql_fetch_object ($ ergebnis)) {echo '& lt; Div class = "panel" & gt; & Lt; A href = "user.php? Lang = '. $ Lang.' & Amp; user = '. $ Line - & gt; username.' '& Gt; & lt; strong & gt; $ line- & gt; Username. & Lt; / strong & gt; & lt; / a & gt; ('$ Row- & gt; Date ..'): 
'$ line- & gt; Text. '& Lt; a href = "com.php? Id = '. $ Line-> FeedID '& Amp; Lang = '. $ Lang '"& Gt; & lt; img src ="' $ line-> Picture. '' & Gt; & Lt; / A & gt; & Lt; Br / & gt; & Lt; A href = "com.php? Id = '. $ Line- & gt; feedID.' & Lt; / l & gt; & # 39; & lt; / div & gt; & # 39; & # 39; lang = '. Lang. & # 39; & gt; $ Xml- & gt; Answer. & Lt; / a & gt; & lt; / div & gt;';}}}} '';}? & Gt;

You have two queries (well, three , But the first one is done twice)

The second query is updated, but it is run separately for each friend. You need to add two to make the ORDER work. Should do some work by doing: choose

  from the feed WHERE in Username (choose friends from friends Where user name = '$ username') you need to do more to the logic of your code by feedID DESC ORDER ORDER, but something like that statement should bring everything at once.  

ObNote - You should use PDO or mysqli for your database connection, because they are too 'safe' besides, I have not tested the above, but at least you should give the right idea .

No comments:

Post a Comment