Skip to main content
Participating Frequently
July 19, 2011
Question

If Recordset not empty redirect

  • July 19, 2011
  • 2 replies
  • 2547 views

I am trying to find a code that will work for a redirect.  I want to check a recordset and if there is information there, I need to redirect them to a different page.  I have tried this code

<?php

if($totalRows_basic_info > 0) {

header ("Location:http://localhost/nameupdate.php");}

?>

This code is not working, can anyone help me with a recordset not empty redirect statement?

This topic has been closed for replies.

2 replies

July 19, 2011

You might want to try changing the > to ==

or you could

<?php

if(empty($totalRows_basic_info)) {

header ("Location:http://localhost/nameupdate.php");}

?>

Participating Frequently
July 19, 2011

Gary would that be if the recordset is empty?  I need to redirect if the recordset is not empty.  If they have already entered information once, I don't want them to enter again.

July 19, 2011

If you want to ask if the recordset is empty, you use

if(empty())

If you want to use if the recordset is NOT emptly, you use

if(!empty())

Inspiring
July 19, 2011

I learned it out of an David Powers Book.

You have to change the example to your needs.

Best regards

<?php if (!empty($row_rsActueel['kortetekst'])) { ?>

<?php echo nl2br($row_rsActueel['kortetekst']); ?>

<?php } ?>