/    Sign up×
Community /Pin to ProfileBookmark

passing a querystring from a WordPress page to a php-script

I installed exec-php and the Hello World test worked fine. I’m trying to run the php code listed below. My problem is that categories.php?category=Accountant does not work, because there is no categories.php, really. What I want is a way for this to work in WP. How can I get the page saved as categories.php to make the querystring-passing work? Or is there another way?

[CODE]<?php

dbh=mysql_connect (“localhost”, “<USERNAME>”, “<PASSWORD>”) or die (‘I cannot connect to the database because: ‘ . mysql_error());
mysql_select_db (“intore_cabd”);*/

// display individual record
if ($category)
{
$result = mysql_query(“SELECT * FROM <code>businesses</code> WHERE <code>category</code> = ‘{$category}’ ORDER by bizname;”, $dbh);
$myrow = mysql_fetch_array($result);
echo “<h2>Category: $category</h2>”;
do
{
printf(“<p><b>%s</b>n<br />”, $myrow[“bizname”]);
printf(“%sn<br />”, $myrow[“description”]);
printf(“%sn<br />”, $myrow[“address”]);
printf(“%sn<br />”, $myrow[“country”]);
printf(“%sn<br />”, $myrow[“telephone”]);
if ($myrow[“url”])
printf(“<a href=”$myrow[7]” target=”_blank”>%s</a>n<br />”, $myrow[“url”]);
if ($myrow[“email”])
printf(“<a href=”mailto:$myrow[8]”>%s</a>n</p><br />”, $myrow[“email”]);
echo”<hr>”;
}while($myrow = mysql_fetch_array($result));
}
else
{// show categories list
$result = mysql_query(“SELECT * FROM categories ORDER BY category”,$dbh);

if ($myrow = mysql_fetch_array($result))
{// display list if there are records to display
do
{
printf(“<a href=”%s?category=%s”>%s</a><br>n”, $PHP_SELF, $myrow[“category”], $myrow[“category”]);
} while ($myrow = mysql_fetch_array($result));
}
else
{// no records to display
echo “Sorry, no records were found!”;
}
}

?>[/CODE]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @rozilla 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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