I've a question regarding php. if anyone could answer it i would be hononured.
thanx in advance.
---------------------------------------------------------------
I have a table in MYSQL named product.
Columns in product are named as pcode(product code ) and purl (product url).
i have to generate a search code such that,
if i enter the pcode in the search text for the corresponding purl,
the webpage corresponding to that url gets displayed as i click the submit
button.
I tried out my best ,in the end i was able to display the url only and not the web page corresponding to that url.
here is the code i tried:.
-------------------------------------------------------------------------
Productmanage.php
-----------------------------
Expand|Select|Wrap|Line Numbers
- <html>
- <title>Product CMS: Search Products</title>
- <body>
- <h1>Manage Products</h1>
- <?php
- include "dbconnect.php";
- // The basic SELECT statement
- $select = 'SELECT DISTINCT pcode,purl ';
- $from = ' FROM product';
- $where = ' WHERE 1=1 ';
- $searchtext = $_POST['searchtext'];
- if ($searchtext != '')
- { // Some search text was specified
- $where .= " AND pcode LIKE '%$searchtext%'";
- }
- ?>
- <table>
- <tr> <th>Product url</th></tr>
- <?php
- $url = @mysql_query($select . $from . $where);
- if (!$url)
- {
- echo '</table>';
- exit('<p>Error retrieving urls from database!<br />'.
- 'Error: ' . mysql_error() . '</p>');
- }
- while ($pdurl = mysql_fetch_array($url))
- {
- echo "<tr valign='top'>\n";
- $id = $pdurl['pcode'];
- $purl = htmlspecialchars($pdurl['purl']);
- //echo "<td>$id</td>\n";
- echo "<td> <a href='link:$purl'>$purl</a>";
- echo "</tr>\n";
- }
- ?>
- </table>
- <p><a href="productsearch.html">New search</a></p>
- </body>
- </html>
Productsearch.html
-----------------------------
Expand|Select|Wrap|Line Numbers
- <html>
- <title>Joke CMS:URL Search </title>
- <body>
- <h3>Search Product URLs from Product Code</h3>
- <form action= "productmanage.php" method="post">
- <label>Containing ProductCode: <input type="text" name="searchtext" />
- </label><br />
- <input type="submit" value="Search" />
- </form>
Please help me to sort out this problem as eary as possible, i have to report to boss to the earnest regarding this work.
Thanx.........yours .........Atif