WHERE ERROR ayuda Urgente
Publicado por JC (2 intervenciones) el 19/05/2006 21:33:03
hola,
Estoy tratando de hacer una forma que muestre los datos de un database, este database contiene informacion sobre transportacion son precios de un viaje de una ciudad a otra.
http://www.cqsinc.net/test/index.php
Estoy hagarrando ese error a la hora de hacer click en rate, creo que no me esta permitiendo verificar con el where dos expreciones!!!
<?
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("cqsicnet_Test") or die(mysql_error());
?>
<form name="form1" method="post" action="index.php">
<div align="left">Origin: </div>
<select name="from" tabindex="1">
<?
$result = mysql_query("SELECT * FROM origins")
or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
echo "<option value=\"$row[id]\">$row[from]</option>";
}
?>
</select><br>
<div align="left">Destination: </div>
<select name="to" tabindex="1">
<?
$result2 = mysql_query("SELECT * FROM destinations")
or die(mysql_error());
while($row2 = mysql_fetch_array( $result2 )) {
echo "<option value=\"$row2[id]\">$row2[to]</option>";
}
?>
</select>
<input type="submit" name="Submit" value="Get Rate">
<div align="right"> <span class="style1">*</span>Rate: </div>
</td>
<td width="76%" class="body">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="body">
</td>
</tr>
<tr>
<td class="body">
<?
if($Submit) {
$res1 = mysql_query("SELECT * FROM origins WHERE id='$from'");
$r1 = mysql_fetch_array( $res1 );
$res2 = mysql_query("SELECT * FROM destinations WHERE id='$to'");
$r2 = mysql_fetch_array( $res2 );
$query3 = "select * from fromtoprices where from='$from' and to='$to'";
$res3 = mysql_query("$query3") or die("MySQL Error: ".mysql_error()."\n<br/>SQL: ".$res3);
$r3 = mysql_fetch_array( $res3 );
echo "The price from $r1[from] to $r2[to] is: $ $r3[price]";
}
else {
echo " Please
calculate the rate. ";
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
Espero que me puedan ayudar en verdad me urge mucho!!! la idea es hacer algo parecido a esto:
http://www.ciatrucking.com/rates.asp
Pero tiene que ser en php (el servidor es linux)
Espero su ayuda!!
Gracias
JC
Estoy tratando de hacer una forma que muestre los datos de un database, este database contiene informacion sobre transportacion son precios de un viaje de una ciudad a otra.
http://www.cqsinc.net/test/index.php
Estoy hagarrando ese error a la hora de hacer click en rate, creo que no me esta permitiendo verificar con el where dos expreciones!!!
<?
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("cqsicnet_Test") or die(mysql_error());
?>
<form name="form1" method="post" action="index.php">
<div align="left">Origin: </div>
<select name="from" tabindex="1">
<?
$result = mysql_query("SELECT * FROM origins")
or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
echo "<option value=\"$row[id]\">$row[from]</option>";
}
?>
</select><br>
<div align="left">Destination: </div>
<select name="to" tabindex="1">
<?
$result2 = mysql_query("SELECT * FROM destinations")
or die(mysql_error());
while($row2 = mysql_fetch_array( $result2 )) {
echo "<option value=\"$row2[id]\">$row2[to]</option>";
}
?>
</select>
<input type="submit" name="Submit" value="Get Rate">
<div align="right"> <span class="style1">*</span>Rate: </div>
</td>
<td width="76%" class="body">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="body">
</td>
</tr>
<tr>
<td class="body">
<?
if($Submit) {
$res1 = mysql_query("SELECT * FROM origins WHERE id='$from'");
$r1 = mysql_fetch_array( $res1 );
$res2 = mysql_query("SELECT * FROM destinations WHERE id='$to'");
$r2 = mysql_fetch_array( $res2 );
$query3 = "select * from fromtoprices where from='$from' and to='$to'";
$res3 = mysql_query("$query3") or die("MySQL Error: ".mysql_error()."\n<br/>SQL: ".$res3);
$r3 = mysql_fetch_array( $res3 );
echo "The price from $r1[from] to $r2[to] is: $ $r3[price]";
}
else {
echo " Please
calculate the rate. ";
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
Espero que me puedan ayudar en verdad me urge mucho!!! la idea es hacer algo parecido a esto:
http://www.ciatrucking.com/rates.asp
Pero tiene que ser en php (el servidor es linux)
Espero su ayuda!!
Gracias
JC
Valora esta pregunta


0