Jump to content

Archived

This topic is now archived and is closed to further replies.

MrRay

BARAND NEEDED -- Boss fails to understand situation, need temporary solution

Recommended Posts

I have setup a static menu, which I want to pass a keyword to a php script that already exists. How would I approach this?


[pre]
<?php
require('top.inc');
require('menu2.inc');


echo "
<div id='main' class='hideMe'>
<span class='content_header'>TEST </span>
<div class='content_box'> \n";


mysql_connect('localhost', 'blah', 'blah');
mysql_select_db('dbname');

$sql = "SELECT (data, number)
        FROM items
        ORDER BY area, locname";
$res = @mysql_query($sql);
$count = 0;
while (list ($data, $n) = mysql_fetch_row($res)) {
    echo "<div class='item_box'>\n
          <div class='item_pic'><a href='$n\.htm'>\n<img class='noborder'  src='styles/Images/lo_res/$n\.jpg'/></a>\n
  <div class='item_content'>\n
                $data\n<br/>Item no\. upper($n)\n</div></div>";
    if (++$count % 4 == 0) {
        echo "\n</div>\n\n";
    }
}
echo "<br/></div></div>\n";
require('content.inc');
require('footer.inc');
?>[/pre]

this code was originally from barand when he helped me out a few weeks ago, but i modified it for my application on the site. I want this code to take what the user sends through the link and make it use this script on that specific data

Share this post


Link to post
Share on other sites
Let's assume the script above is "script2.php" and you have "script1.php" containing your menu.

Something like this:
[code]
<FORM method='POST' action='script2.php'>

<select name="keyword">
  <option value="keyword1">keyword1</option>
  <option value="keyword2">keyword2</option>
  <option value="keyword3">keyword3</option>
</select>
<br>
<input type="submit" name="submit" value="Submit">

</FORM>[/code]

Let's further assume your items table has a column called "keyword_col".

Change this bit
[code]mysql_connect('localhost', 'blah', 'blah');
mysql_select_db('dbname');

$sql = "SELECT (data, number)
        FROM items
        ORDER BY area, locname";[/code]

to

[code]mysql_connect('localhost', 'blah', 'blah');
mysql_select_db('dbname');

$keyword = $_POST['keyword'];

$sql = "SELECT (data, number)
        FROM items
        WHERE keyword_col = '$keyword'
        ORDER BY area, locname";
[/code]

Share this post


Link to post
Share on other sites
you're awesome. when this site gets all of its kinks out and hes happy with it I'm gonna show you it. i owe you one. theres been so much going on and stuff here it wouldve been a nightmare finding time to figure it out. if I can get some free time maybe I'll try to help you guys convert to smf to return the favor :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.