Indigo Rose Software
  #1  
Old 10-12-2004
Derek's Avatar
Derek Derek is offline
Indigo Rose Customer
 
Join Date: May 2001
Location: 51.501296|-2.700963
Posts: 1,206
Help with Dreamweaver/PHP/SQL

I'm playing around with creating a database driven website in Dreamweaver MX 2004 - not something i have done before.

I have search.php with a form and couple menus for the user, and results.php for displaying. It will search MySQL 'bikes' database for MAKE and MODEL.

In search.php, the 2 drop-menu objects in form1 are called 'make' (with values Honda, Kawasaki) and 'model' (with values CBR900, ZZR1100).

The problem arrives with the recordset on results.php
- it works fine if i have sql statement as:
Code:
SELECT bikes.make, bikes.model, bikes.style, bikes.engine, bikes.year FROM bikes WHERE bikes.make = 'Honda' AND bikes.model = 'CBR900'
... but when i change it to variables, it wont work:
Code:
SELECT bikes.make, bikes.model, bikes.style, bikes.engine, bikes.year FROM bikes WHERE bikes.make = 'varMake' AND bikes.model = 'varModel'
I think the problem is not knowing how to enter the info in the variable box. Have read the help files but it only seems to want to tell me about ASP.NET

I tried
Name:varMake
DefaultValue:%
Run-time Value:#Make#
...but its a no-go

Anyone got an idea here please?
__________________
-
- Derek
- ["All glory comes from daring to begin" - fortune cookie]

IR WebHelp: AMS6 SUF7 VP2 TU2
Reply With Quote
  #2  
Old 10-12-2004
JXBURNS's Avatar
JXBURNS JXBURNS is offline
Forum Member
 
Join Date: Apr 2001
Location: Haverhill, Suffolk, UK
Posts: 333
I'm only a very small user of PHP/MYSQL but I would suggest from SQL server knowledge that the variables have to be outside the string of other SQL text.

That is:

Quote:
"SELECT xxx FROM yyyy WHERE string_variable_name = ' " + variablename + " ' "
so that the parser knows you are referring to variablename not a string called 'variablename'.

John
Reply With Quote
  #3  
Old 10-12-2004
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
OK here they have a sample database call:

http://ca3.php.net/mysql

So you would want to use:

Code:
$query="SELECT 'make', 'model', 'style', 'engine', 'year' FROM bikes WHERE make='$varMake' AND model='$varModel'";
Where they have typed:

Code:
$query = "SELECT * FROM my_table";
Of course assuming the variables in the example have been assigned values, i.e.:

$varModel="Raleigh";
$varMake="High Roller";

Hope that helps.

Corey Milner
Creative Director, Indigo Rose Software
Reply With Quote
  #4  
Old 10-17-2004
Derek's Avatar
Derek Derek is offline
Indigo Rose Customer
 
Join Date: May 2001
Location: 51.501296|-2.700963
Posts: 1,206


Thanx for the help guys!
__________________
-
- Derek
- ["All glory comes from daring to begin" - fortune cookie]

IR WebHelp: AMS6 SUF7 VP2 TU2
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -6. The time now is 11:13 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software