Jump to content

Splitting Results up..


cpharry

Recommended Posts

How do i split up the search results from the different tables because if i have two results both with the id 1 when the user clicks on the link which uses the id to get the data from the table it will get confused, so how do i split the results up into say an echoed table for the different tabled results if that makes sense.

 

Character Result Table

----------------------------

Character result id 1

 

Location Result Table

---------------------------

Location result id 1

 

And currently whenever i search for something the entire two tables just echo all the data in them from the name column not what i searched for.

 

<? 
$search = $_POST["search"];

$connection = mysql_connect("localhost","wowbasec","PASSWORD REMOVED");

mysql_select_db("wowbasec_class", $connection);

$query = "select * from characters, location WHERE characters.name='$search' or location.name='$search' ";

$result = mysql_query($query, $connection); 

if (!$result) {
    echo 'Invalid query: ' . mysql_error(). "<br>";
    echo  'SQL Query: ' . $query. "<br>";
    die();
}

while ($r = mysql_fetch_assoc($result)) { // Begin while 

$ts = $r["name"]; 
?>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><a href="view.php?id=<?php echo $r['id'];?>"> <? echo $r['name'] ?></td>
  </tr>
</table>
<? 
}
?>

Link to comment
https://forums.phpfreaks.com/topic/155614-splitting-results-up/
Share on other sites

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.