Jump to content

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


MrRay

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
Link to comment
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]
Link to comment
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 :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.