Hi, The tables are related only by username. Regards Ray
djhankypark
Posts
-
Query on 2 Arrays -
Query on 2 ArraysHi there, I have 2 MySQL databases on 2 different servers and using php am pulling an array from each of them as follows... From Server 1:
$query_Recordset1 = "SELECT login.`id`, login.username, tbl_countries.Country
FROM login, tbl_countries
WHERE login.Country = tbl_countries.id ";
$Recordset1 = mysql_query($query_Recordset1, $NU_Conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);From Server 2:
$query_Recordset2 = "SELECT newusb.ID, newusb.artist, newusb.title, tbl_ply_newusb.Week_14
FROM newusb, tbl_ply_newusb
WHERE tbl_ply_newusb.Song_ID = newusb.ID
ORDER BY tbl_ply_newusb.Week_14 DESC";
$Recordset2 = mysql_query($query_Recordset2, $Chartmenu) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);Between the 2 arrays I am trying to find the most played artists by Country, my thought is to have some sort of join between the artist name as the artist.id does not exist in the second array. Do I create a 3rd array? if so how? Any help on how to bring in a 3rd array based on the 2 existing arrays would be appreciated. Many Thanks Ray
-
Break down URLThank You Graham, The first one only gives me \ for some reason but the question is answered with the second one you gave. Many Thanks Regards Ray
-
Break down URLThis is foxing me a little and I wonder if someone could point me in the right direction please or include what is needed to resolve this. My page at the moment only includes the following and the address(URL) is given as the example.
<?php
//As an example the address is taken as http://www.newusb.co.uk/jh6k95/
$url = $_SERVER['REQUEST_URI'];
//Show me the folder name
echo $url;
?>The return is... /jh6k95/index.php However the only thing I want from that is... jh6k95 So, I suppose the question is how do I strip out folder name. Many thanks in advance for any help. Ray
-
Changing the content of a div tag help requiredHello, I am using a div tag in a page called profiles.php whos left content is being brought in by using require_once...
<div class="divMain_Left">
<?php require_once('left.php'); ?>
</div>whilst this works fine and I have links in the page left.php that is being fed in to the div, I would like when any of these links are clicked to have it open in the same div tag? I have tried the target options but none of them seem to open within the div tag and they just open a new page. If anybody could point me in the right direction please. Many thanks in advance Regards Ray
-
Further Help with Select Required Please [modified]Hi again Luc Pattyn From a quick glance at what you have just put there that might actually do it :) Your patience has been amazing and I wish to say a big thank to you for that. I am sorry if I have caused you lots of stress in trying to figure this, I know I could probably explain things better and of cause it would be eaiser to maybe have let you come and look at the site and pages which has only crossed my mind. Am going to try what you put forward and see what happens :) Many many thanks. Kind regards Ray
-
Further Help with Select Required Please [modified]Sorry yes I will answer by number 1) users are not known to be logged by other users 2) see answer 3 3a) Yes, when the page displaying comments is opened the query is ran for the person logged in i.e. session variable (kt_login_id) 3b) Yes correct, the results are in the order you have put forward. 3c) Lacey will see Eric's comment because he is in her buddies list however Eric will not see any of Lacey's comments because she is not in his buddies list, this should also answer the question number 2 Regards Ray
-
Further Help with Select Required Please [modified]Hi Luc Pattyn People do not know when others are logged in, I suppose it would be easier put this way... A person can only put comments if they are logged in, and they can only comment on profiles of people that are their friends. If Eric is in Lacey's freinds list then lacey can comment on erics profile If Lacey is not in Eric's friends list then Eric can not comment in laceys profile Each user has to ask another to be added to their friends list (Buddies List) These requests can be accepted(approved)in one direction or both directions i.e. allowing them to be added or allowing them to be added and also adding themselves to the requester. This is why the buddy list is there to keep track of who is friends with who in both directions. Regards Ray
-
Further Help with Select Required Please [modified]Hi Luc Pattyn No there is no logged in field. When a user logs in their id (login.id) because a session variable called kt_login_id Many Thanks Regards Ray
-
Further Help with Select Required Please [modified]Hi there :) I think i see where your going with the using of the buddlist_ID in the comments and will need to sit and think on that one to have it clear in my head. Your questions, 1) The active field is if a user account is active or disabled. 2) There maybe a column missing in the login table structure I forgot, I was trying to only show fields that were used in the query. 2A) No all users are active. 2B) As Above Your question of "could it be that simmple?" No, lol I wish it could be that simple lol. The buddylist table is required by the system in other areas of the site so see no need to remove or not use it. Regards Ray
-
Further Help with Select Required Please [modified]:) Ok, here goes... This is the original query...
SELECT
(FU.id)AS ID1,
(TU.id)AS ID2,
(FU.username)AS Username1,
(TU.username)AS Username2,
(FU.level)AS level1,(TU.level)AS level2,
(NU.Profile_Image)AS Image1,
(MU.Profile_Image)AS Image2,
comments.comment
FROM comments
JOIN login as FU ON comments.Artist = FU.id
JOIN login as TU ON comments.Buddy = TU.id
JOIN tbl_profile as NU ON comments.Artist=NU.Usr_AD_ID
JOIN tbl_profile as MU ON comments.Buddy=MU.Usr_AD_ID
WHERE TU.active = 1
ORDER BY comments.commentid DESC LIMIT 10The table structures are as follows including the extra table called tbl_buddylist, and what the output should look like...
Table: Login
id
username
active
Level
23
Lacey
1
4
26
Dave
1
4
232
Eric
1
4
33
Jake
1
4
Table: tbl_profile
id
USER_AD_ID
Biography
Profile_Image
1
23
Some Text About Me
prof_img.jpg
2
26
Some Text About Me
prof_img.jpg
3
232
Some Text About Me
prof_img.jpg
4
33
Some Text About Me
prof_img.jpg
Table: tbl_buddylist
id
Buddy_ID
Author_ID
Description
Approved
1
232
23
Eric
1
2
26
23
Dave
1
3
33
23
Jake
1
4
26
232
Dave
1
5
232
33
Eric
1
-
Further Help with Select Required Please [modified]Hi again Luc Pattyn When you say an example would help? I basically want to include another table in the query so as to break the list to fewer comments being shown your are correct. As a user is logged they have buddies "friends" and that is represented by their login_id in the buddies table, so the account holders login_id is held in the Author_id field of the buddies table. If the user befriends someone else that has an account that persons login_id is held in the buddy_id field of the buddies table. Everytime someone adds a buddy "friend" a new record is added to the table again holding the Author_id and Buddy_id. When a comment is made it puts the Authors id and the buddies id in the comments table, and of cause the comment that has been made. So the query you helped me with previously now has to only show comments to an Author where th person is in their own Buddies list. a bit like myspace really where you only see comments that have been made by your friends and not every man and his dog. I hope i am putting this across in an understandable way lol Kind Regards Ray
-
Further Help with Select Required Please [modified]Hi Luc Pattyn Wow! quick reply :) Seems you are to my rescue again. Many thanks for your support I am really enjoying the learning curve and achiveing so much just for having been pointed in the right directions. Have a great evening, thank you again Regards Ray
-
Further Help with Select Required Please [modified]The code below which was advised works very well, not sure if it was supposed to be laid out that way and was a little learning curve me but it works :) am happy. My next problem is this...
SELECT
(FU.id)AS ID1,
(TU.id)AS ID2,
(FU.username)AS Username1,
(TU.username)AS Username2,
(FU.level)AS level1,(TU.level)AS level2,
(NU.Profile_Image)AS Image1,
(MU.Profile_Image)AS Image2,
comments.comment
FROM comments
JOIN login as FU ON comments.Artist = FU.id
JOIN login as TU ON comments.Buddy = TU.id
JOIN tbl_profile as NU ON comments.Artist=NU.Usr_AD_ID
JOIN tbl_profile as MU ON comments.Buddy=MU.Usr_AD_ID
WHERE TU.active = 1
ORDER BY comments.commentid DESC LIMIT 10I have a tbale which is basically a buddies list... TABLE Structure... ID Buddy_ID Author_ID Description Block Approved I am not sure how to include this so the comments only show comments from a person that is in a user buddies list, if that makes sense. at the moment it shows all comments from and to everyone. As members have to be logged in to see the page I could grab the users login_id from the session variable which would go against the Author_ID in the buddies list table, so only to show comments form people in his/her buddies list. Any pointers would be very much appreciated. King Regards Ray
-- Modified Tuesday, November 23, 2010 2:00 PM
-
MySQL Select help requiredI finally got to sit and try your suggestion and this was wonderful help thank you so much. I do have another question about this which I will post a new messgae for shortly. Again thank you very much for your help Regards Ray
-
MySQL Select help requiredCould someone pont me in the right direction here cos I am pulling my hair out and I have little to start with lol I am working with 3 tables User Table: Auto_ID User_Name Profile Table: Auto_ID User_ID (This is taken from the Auto_ID in the User Table e.g. 20) Prof_Img Comments Table: Auto_ID Message_To (This is taken from the Auto_ID in the User Table e.g. 41) Message_From (This is taken from the Auto_ID in the User Table e.g. 20) Message I need to be able to display the Prof_Img for who the message was _to and _from I just can't figure how to get the individual picture references from the same table in the same query. I can get one of the pictures but not both, am probably not thinking about it correctly, well obviously I am or it would work lol Oh and I need the User_Name to go with each relevant picture If someone could give me a little guidance please it would save my hair line lol Many thanks in advance Regards Ray
-
How to sort the problem of spaces in urls question?Hi there I have a slight problem which io hope someone might be able to help me with... http://www.something.something/profile/index.php?profile\_id=The Long Knives As you can see this would not show as a proper link because of the spaces in the last bit of the url is there a way that i could say use this http://www.something.something/profile/index.php?profile\_id=The\_Long\_Knives And have some php take out the _ before the page opens, i presume this would be some sort of function in php but not being that up with it am not sure, also if the user puts the original url with the spaces it must use that. Thanks you for any help or advice on the matter in advance Regards Ray
-
How can I add the data found from one table to another?Thnak you for both replies I knew I would get the right directions here Many Thanks for you help Regards Ray
-
How can I add the data found from one table to another?Hi I am comparing data between 2 tables looking for what exists in one so i can then enter whatis found into the second table as follows...
mysql_select_db($database_Chartmenu, $Chartmenu);
$query_find_all = "SELECT hankypark.ID FROM hankypark LEFT JOIN tbl_ply_hankypark ON hankypark.ID = tbl_ply_hankypark.Song_ID WHERE (((tbl_ply_hankypark.Song_ID) Is Null))";
$find_all = mysql_query($query_find_all, $Chartmenu) or die(mysql_error());
$row_find_all = mysql_fetch_assoc($find_all);
$totalRows_find_all = mysql_num_rows($find_all);in the hankypark table i know will be entries that do not exist in the tbl_ply_hankypark table hense the Is Null query which gives me an array of the ID field, I now want to add those ID's to the tbl_ply_hankypark table. Question is what do I use to roll through all the ID's found ? My INSERT query looks like this...as said what do use tat the begining is it a... while or do or what?? and how should it be properly laid out please? not having played with arrays I have tried several things from suggestions on the net but none seem to work apart from one that only inserted the first ID and then stopped?
// Insert a row of information into the table "example" mysql_query("INSERT INTO tbl_ply_hankypark (Song_ID) VALUES ('???')")or die(mysql_error());
Thought it best to just bite the bullet and come ask you guys cos your always right lol :) Cheers in advance of any help Regards Ray -
how can I tranfer values from mssql to mysqlBrilliant thank you very much, sorry so long in replying to your answer. That has helped sort things and I do have a similar question which I will post a new thread for. again thank you for your reply and help Regards Ray