/    Sign up×
Community /Pin to ProfileBookmark

taking the url and putting it into query

Hey guys this might be just a noob question but in my sql query for the database how do i set it to say like where industry = and then the id number from the url for its query?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@chesemonkylomaSep 20.2006 — if the url is example.com/index.php?industry=15273, than use the $_GET array, in this case it would be $_GET['industry']
Copy linkTweet thisAlerts:
@Codeman0013authorSep 20.2006 — ok another noob question on the dropdowns that are pulling this information when it submits the page they go back to saying please select an industry when it submits the information how do i get it to stay and still say like Analytical?
Copy linkTweet thisAlerts:
@JDM71488Sep 20.2006 — use the option attribute selected and set it equal to selected. [selected="selected"].

if your select options are in a database you can do something like the following.
[code=php]foreach($industries as $industry)
{
if($industry['value'] == $_GET['industry'])
{
// print option with selected="selected"
}
else
{
// print option
}
}[/code]

or you will have to manually check each option value.
[code=php]if($_GET['industry'] == "a")
{
// print option with selected="selected"
}
else
{
// print option
}
if($_GET['industry'] == "b")
{
// print option with selected="selected"
}
else
{
// print option
}
if($_GET['industry'] == "c")
{
// print option with selected="selected"
}
else
{
// print option
}[/code]
Copy linkTweet thisAlerts:
@Codeman0013authorSep 20.2006 — hey also thanks again for all the help could you help me write an if statement for the following code: [code=php]<tr><td>Product category:</td><td>


<select name="prodcat" id="center" disabled>
<option value="">Select a product category...</option>
<?php do { ?>
<option value="<?php echo $row_rs_productcategory['productCat_name']; ?>"><?php echo $row_rs_productcategory['productCat_name']; ?></option>

<?php } while ($row_rs_productcategory = mysql_fetch_assoc($rs_productcategory)); ?>
</select>[/code]


i would like it to be if industry is selected then enable it if not leave it disabled
×

Success!

Help @Codeman0013 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...