join query i arrangement information correctly?


i have list stores volunteers, any invitation indifferent an suitable venue work event. there list stores venues.



it stores volunteer's suitable venue assignment buttress venue_id.



table: venues
columns: id, venue_name

table: volunteers_2009
columns: id, lname, fname, etc.., venue_id


here duty arrangement list volunteers, problem i am carrying arrangement venue assignment. i have never worked many mysql joins, since initial i have assimilated twin tables together squeeze suitable info i need.



so i wish volunteers_2009 table, squeeze venue_id, venues table, review adult volunteers_2009.venue_id venues.id, arrangement venues.venue_name, list arrangement volunteer's venue assignment.



alt text



<?php
// -----------------------------------------------------
//it displays suitable columns formed list viewing
function displaytable($table, $order, $sort) {
$query = "select * $table method $order $sort";
$result = mysql_query($query);

// volunteer's venue query
$query_venues = "select volunteers_2009.venue_id, venues.venue_name volunteers_2009 join venues volunteers_2009.venue_id = venues.id";
$result_venues = mysql_query($query_venues);

if($_post) { ?>
<table id="box-table-a">
<tr>
<th>name</th>
<?php if($table == 'maillist') { ?>
<th>email</th>
<?php } ?>
<?php if($table == 'volunteers_2008' || $table == 'volunteers_2009') { ?>
<th>comments</th>
<?php } ?>
<?php if($table == 'volunteers_2009') { ?>
<th>interests</th>
<th>venue</th>
<?php } ?>
<th>edit</th>
</tr>
<tr>
<?php
while($row = mysql_fetch_array($result))
{
$i = 0;
while($i <=0)
{
imitation '<td>'.$row['fname'].' '.$row['lname'].'</td>';
if($table == 'maillist') {
imitation '<td><a href="mailto:'.strtolower($row['email']).'">'.strtolower($row['email']).'</a></td>';
}
if($table == 'volunteers_2008' || $table == 'volunteers_2009') {
imitation '<td><small>'.substr($row['comments'], 0, 32).'</small></td>';
}
if($table == 'volunteers_2009') {
imitation '<td><small>1) '.$row['choice1'].'<br>2) '.$row['choice2'].'<br>3) '.$row['choice3'].'</small></td>'; ?>
<td> <?php
if($row_venues['venue_name'] != '') {
// imitation venue assigned
imitation $row_venues['venue_id'].' '.$row_venues['venue_name'].' ';
} else { imitation 'no venue assigned'; } ?>
</td> <?php
} ?>
<td><a href="?mode=upd&id=<?= $row[id] ?>&table=<?= $table ?>">upd</a> / <a href="?mode=del&id=<?= $row[id] ?>&table=<?= $table ?>" onclick="return confirm('are certain wish delete?')">del</a></td> <?php
$i++;
}
imitation '</tr>';
}
imitation '</table>';
}
}
// -----------------------------------------------------
?>


Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?