Forums
This topic is locked
how do you get a 'no results found statement'
Posted 15 Nov 2004 12:41:45
1
has voted
15 Nov 2004 12:41:45 Geofrey Biggins posted:
Hi, I have a multiple search page using php and mysql which works fine except when you search for something that isn't on the database. It then returns no values (obviously) but this leaves people wondering why there is nothing displayed. how do i get it to return a no results found try again statement, if there is no matching results?. Your help will be much apprieciated. Replies
Replied 15 Nov 2004 12:55:02
15 Nov 2004 12:55:02 Janusz Jasinski replied:
well, if you have an 'if' statement saying 'if there is data then....' just do a simple, else statement saying 'no records found'... did you do it using dreamweaver or hand-code?
Janusz
[Win XP] • [Windows 2003 Server] • [SuSE 9.2 Pro] • [FreeBSD 5.3] • [Macromedia Studio 2004] • [ASP.NET] • [ASP] • [PHP] • [C#] • [(DH)(XH)(HT)(X)ML] • [CSS] • [VB] • [Java] • [Making Lasagne]
Janusz
[Win XP] • [Windows 2003 Server] • [SuSE 9.2 Pro] • [FreeBSD 5.3] • [Macromedia Studio 2004] • [ASP.NET] • [ASP] • [PHP] • [C#] • [(DH)(XH)(HT)(X)ML] • [CSS] • [VB] • [Java] • [Making Lasagne]
Replied 15 Nov 2004 13:46:17
15 Nov 2004 13:46:17 Simon Martin replied:
Another option you might wish to consider is server behaviours; Show Region - you could have your "No Records found" info display when there are no results and the normal details when there are results.
Depends how comfortable you are writing code by hand
Sharing knowledge saves valuable time!
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Depends how comfortable you are writing code by hand
Sharing knowledge saves valuable time!
Simon
[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Replied 22 Nov 2004 12:18:56
22 Nov 2004 12:18:56 Geofrey Biggins replied:
Hi, thanks for the replies. Ive done it in dreamweaver as ive only just begun to work with php and mysql. The code below is what iam using. I have 2 tables linked (incase that makes a difference). Iam quite happy to try either as i don't know which is better or easier. Thanks
<pre id=code><font face=courier size=2 id=code>
<?php
$colname2_Recordset1 = "1";
if (isset($HTTP_GET_VARS['region'])) {
$colname2_Recordset1 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['region'] : addslashes($HTTP_GET_VARS['region']);
}
$colname3_Recordset1 = "1";
if (isset($HTTP_GET_VARS['county'])) {
$colname3_Recordset1 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['county'] : addslashes($HTTP_GET_VARS['county']);
}
$colname1_Recordset1 = "1";
if (isset($HTTP_GET_VARS['beach'])) {
$colname1_Recordset1 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['beach'] : addslashes($HTTP_GET_VARS['beach']);
}
mysql_select_db($database_goodbeachguide, $goodbeachguide);
$query_Recordset1 = sprintf("SELECT beach, county, authority, Ntown, region, grade04 FROM gbgmain, gbg_grade WHERE gbgmain.beach = gbg_grade.beaches AND (county = '%s' OR region = '%s' OR beach = '%s' ) ", $colname3_Recordset1,$colname2_Recordset1,$colname1_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $goodbeachguide) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?> </font id=code></pre id=code>
<pre id=code><font face=courier size=2 id=code>
<?php
$colname2_Recordset1 = "1";
if (isset($HTTP_GET_VARS['region'])) {
$colname2_Recordset1 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['region'] : addslashes($HTTP_GET_VARS['region']);
}
$colname3_Recordset1 = "1";
if (isset($HTTP_GET_VARS['county'])) {
$colname3_Recordset1 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['county'] : addslashes($HTTP_GET_VARS['county']);
}
$colname1_Recordset1 = "1";
if (isset($HTTP_GET_VARS['beach'])) {
$colname1_Recordset1 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['beach'] : addslashes($HTTP_GET_VARS['beach']);
}
mysql_select_db($database_goodbeachguide, $goodbeachguide);
$query_Recordset1 = sprintf("SELECT beach, county, authority, Ntown, region, grade04 FROM gbgmain, gbg_grade WHERE gbgmain.beach = gbg_grade.beaches AND (county = '%s' OR region = '%s' OR beach = '%s' ) ", $colname3_Recordset1,$colname2_Recordset1,$colname1_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $goodbeachguide) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?> </font id=code></pre id=code>