Jump to content

[solved thank you all]match making help cheers.


redarrow

Recommended Posts

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]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 WHERE
age= '".$record['age']."' AND hair_color='".$record['hair_color']."' AND
weight='".$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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.