Código PHP:
<h4>Consulta de salidas</h4>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<select name="ruta">
<option value="0" disabled="disabled" selected="selected" style="width: 100px;">Seleccionar ruta</option>
<option value="piuramancora">De Piura a Máncora</option>
<option value="mancorapiura">De Máncora a Piura</option>
</select>
<input type="submit" name="mostrar" value="Consultar" style="background: #2d2d2d; color: #fff;" />
</form><br />
<?php
if($mostrar) {
include('config.php');
if($_POST['ruta'] == 'piuramancora') {
$sql = mysql_query("SELECT * FROM piuramancora");
?>
<h3>Recorrido de Piura a Máncora</h3>
<table style="width: 100%;" cellpadding="0" cellspacing="0">
<tr>
<td class="cabeseras">Piura</td>
<td class="cabeseras">Sullana</td>
<td class="cabeseras">Talara</td>
<td class="cabeseras">El Alto</td>
<td class="cabeseras">Órganos</td>
<td class="cabeseras">Máncora</td>
<td class="cabeseras">Tipo</td>
</tr>
<?php
while($row = mysql_fetch_array($sql)) {
$piura = $row['piura'];
$sullana = $row['sullana'];
$talara = $row['talara'];
$elalto = $row['elalto'];
$organos = $row['organos'];
$mancora = $row['mancora'];
$tipo = $row['tipo'];
?>
<tr>
<td class="result"><?=$piura?></td>
<td class="result"><?=$sullana?></td>
<td class="result"><?=$talara?></td>
<td class="result"><?=$elalto?></td>
<td class="result"><?=$organos?></td>
<td class="result"><?=$mancora?></td>
<td class="result"><?=$tipo?></td>
</tr>
<?php
}
?>
</table>
<?php
}elseif($_POST['ruta'] == 'mancorapiura') {
$sql2 = mysql_query("SELECT * FROM mancorapiura");
?>
<h3>Recorrido de Máncora a Piura</h3>
<table style="width: 100%;" cellpadding="0" cellspacing="0">
<tr>
<td class="cabeseras">Máncora</td>
<td class="cabeseras">Órganos</td>
<td class="cabeseras">El Alto</td>
<td class="cabeseras">Talara</td>
<td class="cabeseras">Sullana</td>
<td class="cabeseras">Piura</td>
<td class="cabeseras">Tipo</td>
</tr>
<?php
while($row2 = mysql_fetch_array($sql2)) {
$piura2 = $row2['piura'];
$sullana2 = $row2['sullana'];
$talara2 = $row2['talara'];
$elalto2 = $row2['elalto'];
$organos2 = $row2['organos'];
$mancora2 = $row2['mancora'];
$tipo2 = $row2['tipo'];
?>
<tr>
<td class="result"><?=$mancora2?></td>
<td class="result"><?=$organos2?></td>
<td class="result"><?=$elalto2?></td>
<td class="result"><?=$talara2?></td>
<td class="result"><?=$sullana2?></td>
<td class="result"><?=$piura2?></td>
<td class="result"><?=$tipo2?></td>
</tr>
<?php
}
?>
</table>
<?php
}else {
echo "<h4>No ha seleccionado ninguna ruta.</h4>";
}
}
?>
La verdad que yo de AJAX no sé mucho, espero que alguien me pueda echar una mano con esto, se lo agradeceré bastante.
Saludos