[PHP] Re: query to display the results without...
Eric Holmstrom wrote: Hi there I have a database called Eric and table name called Rocket'. Table consists of three values. PARTNO | DESCRIPTION | COMMENT So far if i want to show copper headgaskets from the 5r field i put this string into the php script (along with the rest of the html/php code) $sql = SELECT * FROM rocket WHERE partno like '5r%' AND description like 'COPPER HEADGASKET%'; The problem is there is 1000s of different querys i want to run and dont want to make a page for each query. So what im trying to ask is how do i run a query to display the results (like http://www.domain.com/query.php?the query i want to run rather then link to a .php/html file with the query inside of it.) The short answer is to use a GET variable for this. http://example.com/script.php?sql=SELECT... You have to remember to url encode the SQL, though (see urlencode()). You can access it like this: $_GET['sql'] The longer answer is to use a package such as DB_DataObject_FormBuilder (http://pear.php.net/package/DB_DataObject_FormBuilder) to generate this stuff for you. It will take some setup, but once you're used to it, it can make this kind of app happen real quick. -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: query to display the results without...
Okay i have this so far --- ?php $conn = mysql_connect(localhost, , ); mysql_select_db(ERIC,$conn); $sql = SELECT * FROM rocket; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($newArray = mysql_fetch_array($result)) { $partno = $newArray['PARTNO']; $description = $newArray['DESCRIPTION']; $comment = $newArray['COMMENT']; } ? --- How do i make it so if i type http://localhost/test.php?partno=5rdescription=copper Cheers if you can help out! Justin Patrin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Eric Holmstrom wrote: Hi there I have a database called Eric and table name called Rocket'. Table consists of three values. PARTNO | DESCRIPTION | COMMENT So far if i want to show copper headgaskets from the 5r field i put this string into the php script (along with the rest of the html/php code) $sql = SELECT * FROM rocket WHERE partno like '5r%' AND description like 'COPPER HEADGASKET%'; The problem is there is 1000s of different querys i want to run and dont want to make a page for each query. So what im trying to ask is how do i run a query to display the results (like http://www.domain.com/query.php?the query i want to run rather then link to a .php/html file with the query inside of it.) The short answer is to use a GET variable for this. http://example.com/script.php?sql=SELECT... You have to remember to url encode the SQL, though (see urlencode()). You can access it like this: $_GET['sql'] The longer answer is to use a package such as DB_DataObject_FormBuilder (http://pear.php.net/package/DB_DataObject_FormBuilder) to generate this stuff for you. It will take some setup, but once you're used to it, it can make this kind of app happen real quick. -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: query to display the results without...
Eric Holmstrom mailto:[EMAIL PROTECTED] on Monday, December 08, 2003 3:06 PM said: How do i make it so if i type http://localhost/test.php?partno=5rdescription=copper $partno = $_GET['partno']; $description = $_GET['description']; $sql = SELECT partno , description , comment FROM Eric WHERE partno = '$partno' AND description = '$description' ; // execute your sql query HTH, Chris. -- Don't like reformatting your Outlook replies? Now there's relief! http://home.in.tum.de/~jain/software/outlook-quotefix/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: query to display the results without...
Eric Holmstrom wrote: Okay i have this so far --- ?php $conn = mysql_connect(localhost, , ); mysql_select_db(ERIC,$conn); $sql = SELECT * FROM rocket; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($newArray = mysql_fetch_array($result)) { $partno = $newArray['PARTNO']; $description = $newArray['DESCRIPTION']; $comment = $newArray['COMMENT']; } ? --- How do i make it so if i type http://localhost/test.php?partno=5rdescription=copper Cheers if you can help out! Justin Patrin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Eric Holmstrom wrote: Hi there I have a database called Eric and table name called Rocket'. Table consists of three values. PARTNO | DESCRIPTION | COMMENT So far if i want to show copper headgaskets from the 5r field i put this string into the php script (along with the rest of the html/php code) $sql = SELECT * FROM rocket WHERE partno like '5r%' AND description like 'COPPER HEADGASKET%'; The problem is there is 1000s of different querys i want to run and dont want to make a page for each query. So what im trying to ask is how do i run a query to display the results (like http://www.domain.com/query.php?the query i want to run rather then link to a .php/html file with the query inside of it.) The short answer is to use a GET variable for this. http://example.com/script.php?sql=SELECT... You have to remember to url encode the SQL, though (see urlencode()). You can access it like this: $_GET['sql'] The longer answer is to use a package such as DB_DataObject_FormBuilder (http://pear.php.net/package/DB_DataObject_FormBuilder) to generate this stuff for you. It will take some setup, but once you're used to it, it can make this kind of app happen real quick. -- paperCrane Justin Patrin At this point, I will recommend you to ANY PHP tutorial and the PHP manual. The point of these lists is to help after you've tried things, not to write your code for you. -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php