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]
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
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.
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.