Help with php redirect.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I need to put an else condition in the below code. So that if a data is not
found after the search is executed by the user, he/she is redirected to a
sorry page. Don't know how to do it, please advice.

Please note that this code is working absolutly fine, its just that I tried
various combination of ifelse conditions but could not sort it out.

The code:

</tr>
</thead>

<tbody>
					

<?php

// database information
   $host = 'localhost';      
   $user = 'xxxx';
   $password = 'xxxx';
   $dbName = 'xxxx';
   $hello = $_REQUEST['hello'];

mysql_connect(localhost,$user,$password);
@mysql_select_db($dbName ) or die( "Sorry But There Seems To Be A Problem
Connecting To The Database");

$query="SELECT * FROM xxxx WHERE hello = '$hello'";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

$i=0;
while ($i < $num) {

$showThis=mysql_result($result,$i,"showThis");


echo "
<tr>
<td>$showThis</td>

</tr>";

$i++;
}
?>

</tbody></table></div>

So, if the showThis is not achieved or if the user puts it wrong data ... he
should be redirected to an error page or should get an error message on the
same result page, instead of the blank table.

How to achieve this, please advice.

Thanks in advance
-- 
View this message in context: http://www.nabble.com/Help-with-php-redirect.-tf2789498.html#a7782639
Sent from the Php - Database mailing list archive at Nabble.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux