MrRay Posted July 22, 2006 Share Posted July 22, 2006 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]<?phprequire('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 Quote Link to comment Share on other sites More sharing options...
Barand Posted July 22, 2006 Share Posted July 22, 2006 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] Quote Link to comment Share on other sites More sharing options...
MrRay Posted July 24, 2006 Author Share Posted July 24, 2006 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 :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.