redarrow Posted October 13, 2006 Share Posted October 13, 2006 can you help cheers.what i am trying to do is match information from the current user using the id='$id' form a session then do a while loop and select the same database field and show all those user that match.[code]<?php sesion_start();//database information.$query1="SELECT * FROM members_profile WHERE id='$id'";$result1=mysql_query($query1);while($record=mysql_fetch_assoc($result1)){$query2="SELECT * FROM members_profile WHERE '".$record['age']."'='$age' AND '".$record['hair_color']."'='$hair_color' AND '".$record['weight']."'='$weight'";$result2=mysql_query($query2);while($row=mysql_fetch_assoc($result2)){echo" Your match is <br> Users Name: <br> '".$row['name']."' <br> Users age: '".$row['age']."' <br> Users weight: <br> '".$row['weight']."' <br>";} }?>[/code] Quote Link to comment Share on other sites More sharing options...
craygo Posted October 13, 2006 Share Posted October 13, 2006 Don't put your first query in a while statement. Really no need to since you a only looking for one record anyway. Also why are you using variables for field names in your where clause. You won't get anything back looking for an age field named 34.I do not know your field names but you should be looking for something like this[code]$query2="SELECT * FROM members_profile WHERE age = '".$record['age']."' AND hair_color = '".$record['hair_color']."' AND weight = '".$record['weight']."'";[/code]Ray Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 13, 2006 Author Share Posted October 13, 2006 craygo i woke up and wanted to no how to do this match making thing it was on my mind so the whole code is for pratice only.remember i dont no mysql relly well but i am getting there with the help of you guys/ladies cheers mate. Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 13, 2006 Author Share Posted October 13, 2006 is this correct then as the final code cheers.[code]<?php sesion_start();//database information.$query1="SELECT * FROM members_profile WHERE id='$id'";$result1=mysql_query($query1);$record=mysql_fetch_assoc($result1);$query2="SELECT * FROM members_profile WHEREage= '".$record['age']."' AND hair_color='".$record['hair_color']."' ANDweight='".$record['weight']."' ";$result2=mysql_query($query2);while($row=mysql_fetch_assoc($result2)){echo" Your match is <br> Users Name: <br> '".$row['name']."' <br> Users age: '".$row['age']."' <br> Users weight: <br> '".$row['weight']."' <br>";} ?>[/code] Quote Link to comment 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.