Re: query to display the results without...
| From: | Justin Patrin | Date: | Mon, 08 Dec 2003 23:47:08 +0000 |
| Subject: | Re: query to display the results without... | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172188@lists.php.net to get a copy of this message | ||
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)) {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>$partno = $newArray['PARTNO']; $description = $newArray['DESCRIPTION'];$comment = $newArray['COMMENT']; } ?> ----------------------------------------------------------- How do i make it so if i type http://localhost/test.php?partno=5r&description=copper Cheers if you can help out! "Justin Patrin" <papercrane@reversefold.com> wrote in message news:20031208224125.86629.qmail@pb1.pair.com...Eric Holmstrom wrote:likeHi 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 descriptionrun'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 ihttp://www.domain.com/query.php?"thea query to display the results (likequery 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>