close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


Redirect if Recordset Empty while passing URL parameter

Thread began 6/20/2012 2:58 pm by Justin@AdventDesign | Last modified 8/19/2012 5:07 pm by Ian S | 1629 views | 5 replies |


Redirect if Recordset Empty while passing URL parameter

I'm sure this will be quick for a PHP guy. I want to redirect a page from the update page to the insert page if the results of the query are empty. But, I need to pass the URL parameter along to the redirected page, and can't figure out how to do that.

A typical update page URL would be tbProducts_RelatedUpdate.php?id=PS280

Here's as far as I've gotten:

if ($row_rsLikeItems < 1)
{ header("Location: tbProducts_RelatedInsert.php?id="); }

Sign in to reply to this post

Jason ByrnesWebAssist

here ya go:

<?php if ($totalRows_rsLikeItems == 0) { 
header("Location: tbProducts_RelatedInsert.php".(isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != ""?"?".htmlentities($_SERVER["QUERY_STRING"], ENT_QUOTES):"").""); 

Sign in to reply to this post


It looks like you have an extra curly bracket at the end. Removed and it works great. Thanks a million!

Sign in to reply to this post

Jason ByrnesWebAssist

ooops, your right, original post has been updated.

Sign in to reply to this post


IF then statement if no records returned by query

I want display a custom message if no records returned:

mysql_select_db($database_dbtpg, $dbtpg);
$query_Recordset1 = "SELECT * FROM products WHERE ProductCategoryID = 'Camark'";

If no records then
custom message
else goto line number or something like this

$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $dbtpg) or die(mysql_error());

Thanks Dan

Sign in to reply to this post

Ian S

Something like this will do the trick:

if ($totalRows_Recordset1 == 0) {
// Content to be shown with no records in results goes here
} else {
// Content to be shown with some records in results goes here


Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...