Adobe Dreamweaver Forums



Last 10 THreads :         Visited Link appears as default (Last Post : Mark A. Boyd - Replies : 6 - Views : 7 )           »          Can't uninstall dreamweamweaver cs4 beta (Last Post : Mark A. Boyd - Replies : 7 - Views : 29 )           »          Dreamweaver 8 problem (Last Post : Mark A. Boyd - Replies : 6 - Views : 9 )           »          IE problem- in same versionsite looks different (Last Post : Mark A. Boyd - Replies : 4 - Views : 8 )           »          Question about filtering commas (Last Post : andy99 - Replies : 0 - Views : 1 )           »          Advanced datagrid using Remote Objects (Last Post : Amy Blankenship - Replies : 6 - Views : 7 )           »          catching errors from remotely invoked processes (Last Post : Amy Blankenship - Replies : 5 - Views : 6 )           »          Frontpage applets to DW?? (Last Post : Alan - Replies : 1 - Views : 2 )           »          RoboHelp hanging (Last Post : shawntrident - Replies : 6 - Views : 7 )           »          RoboHelp & Knowledge Bases (Last Post : Captiv8r - Replies : 3 - Views : 4 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Dreamweaver: Main > Dreamweaver Application Development
 
Tags: , , , , , ,



Reply
  #1 (permalink)  
Old 04-13-2008, 02:51 AM
mac-in-the-mountains
 
Posts: n/a
Diggs:
Default defining recordset according to first three digits ofcode

I need to create a recordset which contains records matching the first three
digits only of a URL parameter.

I have a recordset that contains records matching the code exactly (attached
below)

I need also to create a recordset which contains records that match the first
three digits ONLY of a URL parameter.
I guess it may also be an option to duplicate the parameter in the URL and
restrict the duplicate to three digits only - that way making the creation of
the recordset easy - but I don't know how to do that either.

Can anyone help me out with this one?

Cheers


Dave



$query_rs_allcourses = sprintf("SELECT * FROM courses WHERE coursecode LIKE
CONCAT('%%', %s, '%%') ORDER BY title ASC",
GetSQLValueString($colname_rs_allcourses, "text"));
$rs_allcourses = mysql_query($query_rs_allcourses, $con_dcc) or
die(mysql_error());
$row_rs_allcourses = mysql_fetch_assoc($rs_allcourses);
$totalRows_rs_allcourses = mysql_num_rows($rs_allcourses);



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-13-2008, 02:51 AM
MikeL7
 
Posts: n/a
Diggs:
Default Re: defining recordset according to first three digitsof code

You could create a substring from your parameter and then use that in your
query, if the URL variable was named strParam, you could do this in php
$param = $_GET['strParam'];
$paramThree = substr($param,0,3);
Then use the $ParamThree in your query, you might want to include the sprintf
for security.
Check this link
http://us3.php.net/manual/en/function.substr.php

Reply With Quote
  #3 (permalink)  
Old 04-13-2008, 02:51 AM
mac-in-the-mountains
 
Posts: n/a
Diggs:
Default Re: defining recordset according to first three digitsof code

Thanks Mike,

looks like that's probably the answer but when I start to make changes the
Dreamweaver recordset panel doesn't seem to like it too much. Maybe I'm better
just working in the code:

Anyway I've given it a go a few times and got myself pretty mixed up now.
Here's the code I ended up with. Any idea where I'm going wrong?

Dave

$unstrippedcode = $_GET['code'];
$strippedcode = substr($unstrippedcode,0,3);

$colname_rs_allcourses = "-1";
if (isset($strippedcode)) {
$colname_rs_allcourses = (get_magic_quotes_gpc()) ? $strippedcode :
addslashes($strippedcode);
}
mysql_select_db($database_con_dcc, $con_dcc);
$query_rs_allcourses = sprintf("SELECT * FROM courses WHERE coursecode LIKE
'$strippedcode'", GetSQLValueString($colname_rs_allcourses, "text"));
$rs_allcourses = mysql_query($query_rs_allcourses, $con_dcc) or
die(mysql_error());
$row_rs_allcourses = mysql_fetch_assoc($rs_allcourses);
$totalRows_rs_allcourses = mysql_num_rows($rs_allcourses);

Reply With Quote


  #4 (permalink)  
Old 04-13-2008, 02:51 AM
MikeL7
 
Posts: n/a
Diggs:
Default Re: defining recordset according to first three digitsof code

What error message are you getting, probably in this line

$query_rs_allcourses = sprintf("SELECT * FROM courses WHERE coursecode LIKE
'$strippedcode'", GetSQLValueString($colname_rs_allcourses, "text"));

Try this:
$query_rs_allcourses = sprintf("SELECT * FROM courses WHERE coursecode LIKE
'%$strippedcode%'");



Reply With Quote
  #5 (permalink)  
Old 04-13-2008, 02:51 AM
mac-in-the-mountains
 
Posts: n/a
Diggs:
Default Re: defining recordset according to first three digitsof code

Thanks Mike,

Before I made your changes I had no error message just no data in the drop
down menu thats populated by the recordset. After I change the line you
suggested I get a white screen with - 'Query was empty" on it.

Seems your changes are getting me closer.

Any more suggestions.

Cheers


Dave

Reply With Quote
  #6 (permalink)  
Old 04-13-2008, 02:51 AM
MikeL7
 
Posts: n/a
Diggs:
Default Re: defining recordset according to first three digitsof code

I made a rs with DW8 and got code a little different, try using this line for your query

$query_rs_allcourses = "SELECT * FROM courses WHERE coursecode LIKE '%$strippedcode%'";

Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 08:41 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk