php-general Digest 2 Nov 2012 15:16:00 -0000 Issue 8028
Topics (messages 319638 through 319649):
Re: TURBOPY cloud framework + IDE beta available NOW
319638 by: Adam Richardson
319643 by: Marco Behnke
319644 by: Marco Behnke
319647 by: Adam Richardson
Re: Multithreading for OOP PHP
319639 by: Larry Garfield
319640 by: Matijn Woudt
319641 by: Tommy Pham
319645 by: Dotan Cohen
319646 by: Alex Nikitin
ZendCodeAnalyzer oddity
319642 by: Christoph Boget
319648 by: tamouse mailing lists
Creating an Advanced Form
319649 by: Jonathan Davies
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Tue, Oct 30, 2012 at 7:33 AM, ma...@behnke.biz <ma...@behnke.biz> wrote:
>
> In times of testability and several design patters, the use of static
> calls is
> really outdated.
> I understand that you can read and write the invocations of the methods
> much
> faster, but you should think more to the future on that point.
What?
Where is it written that the use of static calls is really outdated?
Functional programming is on the rise, and this is largely because of the
virtues of testability, scalability, and simplified patterns. Using a class
to organize a set of static functions can benefit the code in PHP (allow
for autoloading in PHP because functions can't be autoloaded, essentially
serves as a child namespace, etc.) whilst maintaining the benefits of a
more functional approach (unit testing purely written static functions is
much easier, putting all IO tasks in separate components makes for cleaner
modules, etc.)
I try to emulate functional approaches in PHP, such as what you'd find in
Scala, Clojure, or Haskell, and static calls in PHP can facilitate this
approach.
While OOP is one way to approach programming, it's not the only way. Even
Rasmus has said he leans procedurally:
http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html
Adam
--
Nephtali: A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com
--- End Message ---
--- Begin Message ---
Am 31.10.12 18:13, schrieb Adam Richardson:
> On Tue, Oct 30, 2012 at 7:33 AM, ma...@behnke.biz <ma...@behnke.biz> wrote:
>
>> In times of testability and several design patters, the use of static
>> calls is
>> really outdated.
>> I understand that you can read and write the invocations of the methods
>> much
>> faster, but you should think more to the future on that point.
>
> What?
>
> Where is it written that the use of static calls is really outdated?
> Functional programming is on the rise, and this is largely because of the
> virtues of testability, scalability, and simplified patterns. Using a class
> to organize a set of static functions can benefit the code in PHP (allow
> for autoloading in PHP because functions can't be autoloaded, essentially
> serves as a child namespace, etc.) whilst maintaining the benefits of a
> more functional approach (unit testing purely written static functions is
> much easier, putting all IO tasks in separate components makes for cleaner
> modules, etc.)
I mentioned in an earlier post on the list, why I - and "some others" -
think, the use of static methods is somehow outdated.
1. If you have code using static methods and members and use phpunit for
testing it, you have to either make sure, that everything is properly
resetted after use OR have to run phpunit in a mode where every test is
run in a single php call for itself. One is potentially harmful to the
test if you forgot some side effects and one is time consuming.
2. When thinking about dependency injection (give everything you use
inside, from the ouside in), show me how one can do this with classes
WITHOUT passing strings around? And without DI, how do you keep your
application flexible to different environments and conditions?
>
> I try to emulate functional approaches in PHP, such as what you'd find in
> Scala, Clojure, or Haskell, and static calls in PHP can facilitate this
> approach.
>
> While OOP is one way to approach programming, it's not the only way. Even
> Rasmus has said he leans procedurally:
> http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html
Are you serious quoting that post?
Posted by Rasmus <http://toys.lerdorf.com/authors/1-Rasmus> on Monday,
February 27. 2006
>
> Adam
>
--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3
Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz
Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal
http://www.behnke.biz
signature.asc
Description: OpenPGP digital signature
--- End Message ---
--- Begin Message ---
Am 31.10.12 18:13, schrieb Adam Richardson:
> While OOP is one way to approach programming, it's not the only way. Even
> Rasmus has said he leans procedurally:
> http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html
Found another interesting discussion on that topic:
http://stackoverflow.com/questions/1185605/when-to-use-static-vs-instantiated-classes
--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3
Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz
Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal
http://www.behnke.biz
signature.asc
Description: OpenPGP digital signature
--- End Message ---
--- Begin Message ---
On Wed, Oct 31, 2012 at 4:46 PM, Marco Behnke <ma...@behnke.biz> wrote:
>
> 1. If you have code using static methods and members and use phpunit for
> testing it, you have to either make sure, that everything is properly
> resetted after use OR have to run phpunit in a mode where every test is run
> in a single php call for itself. One is potentially harmful to the test if
> you forgot some side effects and one is time consuming.
>
There are "potentially harmful" conditions are present in all unit tests.
If there's an error in the test, you find it and fix it, whether it's due
to a failure to reset the static properties, accidental mutation of data,
instantiating the wrong object, etc.
> 2. When thinking about dependency injection (give everything you use
> inside, from the ouside in), show me how one can do this with classes
> WITHOUT passing strings around? And without DI, how do you keep your
> application flexible to different environments and conditions?
>
> I try to emulate functional approaches in PHP, such as what you'd find in
> Scala, Clojure, or Haskell, and static calls in PHP can facilitate this
> approach.
>
> While OOP is one way to approach programming, it's not the only way. Even
> Rasmus has said he leans
> procedurally:http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html
>
> Are you serious quoting that post?
> Posted by Rasmus <http://toys.lerdorf.com/authors/1-Rasmus> on **Monday,
> February 27. 2006
> **
>
Yes, seriously, I quoted that post. There is nothing inherently wrong with
a procedural approach to programming, an OO approach to programming, a
functional approach to programming, an AO approach to programming, etc.
Each has there advantages, and not all are available when programming in
particular languages.
When I code in C, I'm not thinking in OO terms. Although I do sometimes use
function pointers in a way that allows me to emulate functional
programming, I'm mostly thinking in procedural terms because the language
affords this.
When I coded in Clojure, I learned to think in immutable terms and embrace
meta-programming.
As I'm learning Go, I'm learning how to think in terms of data and
algorithms involving a clean, convenient separation using interfaces.
When I code in PHP, I tend to take a functional programming approach. But,
I'll sometimes use OOP principles if the situation feels right (although
this is rare.)
Now, back to your comment on DI. DI is cool for OOP, but I don't find I
need it as much when I'm working from a functional programming paradigm.
Others have spoken on the topic of DI in functional languages, but I tend
to use other approaches, such as passing in first-class functions (PHP's
Closure objects create the appearance of this.)
Adam
--
Nephtali: A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com
--- End Message ---
--- Begin Message ---
On 10/31/12 1:58 AM, Florian Müller wrote:
Hi guys
I was wondering, what actually the reason is that PHP itself does not support
multi-threading?
I guess this would be realizable, or not? If not, why?
Maybe this is a stupid question, but still somehow interesting. Realization in
a way as Java does (or just something in that way) would actually be a very
nice thing, don't you think?
Thank you for your answers :)
Florian
PHP is by design a shared-nothing architecture. What's happening in one
process/request cannot impact what's in another request. They may both
write out to the same external service (DB, memcache, etc.), but they do
not interact. That makes the program much much simpler, since you don't
need to worry about state synchronization. It also means you can scale
up by just adding more servers, because you don't need to deal with "oh,
now the memory isn't shared, so now what do I do?" Each PHP process
could be in its own CPU core, CPU, server, or server cluster, and the
code doesn't change in the slightest.
The "shared nothing" architecture is a very deliberate design decision,
and is in a large part responsible for PHP's success.
--Larry Garfield
--- End Message ---
--- Begin Message ---
On Wed, Oct 31, 2012 at 11:37 AM, Florian Müller
<florian-muel...@outlook.com> wrote:
> I actually tought about just the same structures as Java uses(something in
> this way:
> Thread t = new Thread(new Runnable() { public void run() {
> ...blabla }}
> I thought this would actually be a good benefit if PHP supported this. It's
> just as we sometimes use PHP for doing some big Server works (e.g. database
> copying or something) and it would be nice to controll by yourself which
> Thread (or process) does which part of the job.
> For normal HTTP calls which must be handled within milliseconds, this
> actually does not make sense, that's right ;)
>
Hi,
Have you seen the pcntl[1] and pthreads[2] extensions?
pcntl extension provides a pcntl_fork function, which is also some
kind of threading. Pthreads is almost like it's Java equivalent.
- Matijn
[1] http://www.php.net/manual/en/book.pcntl.php
[2] http://www.php.net/manual/en/book.pthreads.php
Ps. Please don't top post on this mailing list.
--- End Message ---
--- Begin Message ---
On Wed, Oct 31, 2012 at 9:27 AM, Alex Nikitin <niks...@gmail.com> wrote:
>>
>> That's all understood but there are times when that one request from
>> the visitor requires many sub-requests like connection to DB and
>> making SOAP calls.
>
>
> I would say it's more than just "there are times", that's how a typical
> script lives, it imports libraries, queries the database, and talks to other
> systems.
>
>>
>> Sure, it can much faster do you think the response
>> time for the visitor when the sub requests are done in child threads?
>
>
> I am not so sure of that. Let's make it a mental exercise really quickly. So
> let's say we have a website, lets say that we want to query the database and
> make 2 soap calls at the same time, so for every request we spawn 3 threads
> to do this. Now, ofcourse for every single request, if they were not
> concurrent, we would run faster, but what happens when we add a little load
> to this, say 300 requests per second (and i have built wordpress instances
> that do 360 on a small ec2 instance). You have say 4 cores @ 1 thread/core,
> so your web server has 4 threads that are continuously running + 1 for
> dispatch, and then you have 900 threads that you now have to spawn, process,
> transfer execution to other threads (context switch in and out, maybe a few
> time) and terminate per second. The problem is that modern CPUs are not very
> good at doing this, you are context switching between threads, you are
> context switching between cores, because your network stack runs on a
> different core or for any other reason, etc, which is very expensive
> computationally, on top of which you have to spawn new threads and then kill
> them. And on a say 4 requests per second system, you may win a few
> miliseconds on parallelizing your data aggregation, but any real load will
> see that benefit turn in a negative direction.
>
> Curl multi is not necessarily a hack, in context of soap, i can build my
> soap queries, which is always a serial process anyways, and then use curl
> multi to run the soap requests in parallel, so there, one part already
> solved.
>
How is it solved when you can't monitor and actively maintain each
individual requests within curl_multi? Since nothing is shared,
you'll need some place store that information (ie memached or DB).
With memached, you're already using extra memory and CPU cycles for
that. How is that different than what you describe with extra CPU
cycles and RAM? Other than using memcached for something that's not
intended by design? If you're using DB, that's even worse because now
you're relying on extra network traffic and disk IO (read slower
performance). What about synchronizing the information between each
calls in the sub-threads? If you got it solved with curl_multi, I'd
love to see that pseudo code. I'm sure there are many here that would
like to see that too. Anyway, this topic of threading in PHP has
already been discussed heatedly. I'm sure it's already been submitted
as feature request. As with all feature request, it's up to the dev.
:)
Cheers,
Tommy
> Database is even easier, since you are usually using a persistent
> connection, you are already relying on the mysql driver to thread your calls
> while maintaining a single instance of your connection (eliminating the need
> for three way hand shakes every time you want to talk to your database,
> which saves you at least 3 round trips, plus auth (which is 3 more round
> trips and crypto on both sides)), so even there this problem is already
> solved for you. And if you are saying that you can run multiple parallel
> queries for the same PHP process, you really need to fix your database and
> queries first :)
>
>> Then shouldn't that be fixed in PHP at the core rather than a hack after?
>
>
> Nope, no need to needlessly complicate PHP especially if there is no need or
> performance gain in doing it. There are plenty of other areas where PHP can
> be fixed where it does matter, i mean have a look at a month of PHP bugs if
> you want to get depressed :)
>
> --
> The trouble with programmers is that you can never tell what a programmer is
> doing until it’s too late. ~Seymour Cray
--- End Message ---
--- Begin Message ---
> It's just as we sometimes use PHP for doing some big Server works (e.g.
> database copying or something) and
> it would be nice to controll by yourself which Thread (or process) does which
> part of the job.
>
I don't suppose that the client is sitting there waiting for a reply
until the browser times out while the code is database copying or
something. That is why you should hand off the database copying to an
application that does that and then return to the client a response
quickly.
exec("mysqldump");
You could even give the client and AJAX page and inform them of the
status of the operation if the application that you passed off the
work to supports it.
I have wished for PHP threading many times, and my current "big
client" also asked for PHP threading recently. Yet, every single time
that I've devised an alternative solution I was glad that I did. PHP
is not memory efficient and we really don't need it hogging up the CPU
when a real C program can do the intensive work. And if you need
threading, then you are very likely looking at exactly the type of
workload that PHP is designed not to do!
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
--- End Message ---
--- Begin Message ---
You do all that in the context of a single PHP instance and linear code,
calling curl_multi handles its own threading, you just get back results,
you dont have to store it anywhere outside PHP memory space, and you can
configure timeouts and all that stuff, or you can regulate it yourself. The
database connector is already doing what it is doing and doing it darn
well, and you are still in the same execution context just a few lines
down; call out to db, call out to multi for soap requests, handle the
results, no syncing issues, no ITC issues, fast, linearly salable. Thread
communication, sync, messaging, thread-safe storage, that you would be
introduced with threads, and is one that is not there now.
"Since nothing is shared, you'll need some place store that information (ie
memached or DB).
No idea what you are asking about...
--
The trouble with programmers is that you can never tell what a programmer
is doing until it’s too late. ~Seymour Cray
--- End Message ---
--- Begin Message ---
Consider the following code:
<?php
class bob
{
static function factory()
{
echo 'In factory!<br>';
}
}
bob::factory();
$var = 'bob';
$var::factory();
?>
When I run this, "In Factory!" is displayed twice, as I would expect.
So by all accounts, there's nothing wrong with the code. However, when
I run that file through ZendCodeAnalyzer, I get the following error:
(line 11): Zend Engine message: parse error
[Zend Code Analyzer] Aborted.
Line 11 is this:
$var::factory();
So why is ZendCodeAnalyzer reporting that as a parse error? Shouldn't
it behave as PHP does and play nice with it?
I'm running PHP 5.3.15, Zend Code Analyzer 1.2.2
thnx,
Christoph
--- End Message ---
--- Begin Message ---
On Wed, Oct 31, 2012 at 3:42 PM, Christoph Boget
<christoph.bo...@gmail.com> wrote:
> Consider the following code:
>
> <?php
> class bob
> {
> static function factory()
> {
> echo 'In factory!<br>';
> }
> }
>
> bob::factory();
> $var = 'bob';
> $var::factory();
> ?>
>
> When I run this, "In Factory!" is displayed twice, as I would expect. So by
> all accounts, there's nothing wrong with the code. However, when I run that
> file through ZendCodeAnalyzer, I get the following error:
>
> (line 11): Zend Engine message: parse error
> [Zend Code Analyzer] Aborted.
>
> Line 11 is this:
>
> $var::factory();
>
> So why is ZendCodeAnalyzer reporting that as a parse error? Shouldn't it
> behave as PHP does and play nice with it?
>
> I'm running PHP 5.3.15, Zend Code Analyzer 1.2.2
>
> thnx,
> Christoph
I'm not sure why ZendCodeAnalyzer would think that's an error. Maybe try:
${var}::factory();
and see if it still dislikes it.
--- End Message ---
--- Begin Message ---
Hi,
I am attempting to create an advanced form with 9 different search fields.
I am using the WHERE 1 AND sql function to add onto the generated end sql
function so I don't have to created over 300,000 IF statements. The code below
is showing up this error:
[quote]Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL
result resource in
/var/www/vhosts/numyspace.co.uk/web_users/home/~unn_w11014928/public_html/search.php
on line 261[/quote]
I cannot seem to hit the nail on the bud to why it shouldn't work.
[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search CDs</title>
<link rel="stylesheet" href="stylesheets/style.css" type="text/css" media="all"
/><!--Main stylesheet-->
<link rel="icon" href="favicon.ico" type="image/x-icon" /><!--Thumb image for
broswer tab-->
</head>
<body>
<div id="container">
<div id="menu">
<div id="logo">
<a href="index.html"><img src="images/Logo.gif" alt="" /></a>
</div><!--end logo div-->
<div id="navigation">
<ul>
<li ><a href="index.html">Home</a></li>
<li><a href="cd.php">CDs</a></li>
<li><a href="search.php" class="selected">Search</a></li>
<li><a href="admin.php">Administrator</a></li>
<li><a href="credits.html">Credits</a></li>
</ul>
</div><!--end navigation div-->
</div><!--end menu div-->
<div id="main-body">
<div id="article">
<div id="top-search-bar">
<form id="advsearch" action="search.php" method="get">
<div><h2>Advanced Search</h2></div>
<div id="CDTitle">Search CD Title: <input type="text"
name="search"></input></div>
<div><br /><br /><hr /></div>
<div><h5>Search by ID</h5></div>
<div id="CDID">CD ID: <input type="text"
name="searchCDID" maxlength="4" size="3"></input></div>
<div id="pubID">Publisher ID: <input type="text"
name="searchPubID" maxlength="3" size="3"></input></div>
<div id="catID">Category ID: <input type="text"
name="searchCatID" maxlength="2" size="3"></input><br /><br /></div>
<div><br /><br /><hr /></div>
<div id="price">Search by Price:
<input type="radio" name="price" value="7-8"/>£7-8
<input type="radio" name="price" value="8-9"/>£8-9
<input type="radio" name="price"
value="9-10"/>£9-10
<input type="radio" name="price"
value="10-11"/>£10-11
<input type="radio" name="price"
value="11-12"/>£11-12
</div><!--end price div-->
<div><br /><br /><hr /></div>
<?php
include ('connect.php');
$sqlCat = "SELECT * FROM `nmc_category` ORDER BY
catDesc Asc";
$rsCat = mysql_query($sqlCat);
echo "<div id=\"category\">
Search by Category: <select name=\"category\">";
while ($row = mysql_fetch_assoc($rsCat)) {
$catID = $row['catID'];
$catDesc = $row['catDesc'];
echo "<option value=\"$catID\">$catDesc</option>";
}
echo "</select></div>";
?>
<?php
$sqlYear = "SELECT DISTINCT CDYear FROM `nmc_cd` ORDER BY CDYear Asc";
$rsYear = mysql_query($sqlYear);
echo "<div id=\"CDYear\">
Search by Year: <select name=\"year\">
<option value=\"#\"></option>";
while ($row = mysql_fetch_assoc($rsYear)) {
$CDYear = $row['CDYear'];
echo "<option value=\"$CDYear\">$CDYear</option>";
}
echo "</select></div><br /><br /><hr />";
?>
<?php
$sqlPubName = "SELECT * FROM `nmc_publisher` ORDER BY pubName Asc";
$rsPubName = mysql_query($sqlPubName);
echo "<div id=\"PubName\">
Search by Publisher: <select name=\"pName\">
<option value=\"#\"></option>";
while ($row = mysql_fetch_assoc($rsPubName)) {
$pubID = $row['pubID'];
$location = $row['location'];
$pubName = $row['pubName'];
echo "<option value=\"$pubID\">$pubName</option>";
}
echo "</select></div>";
?>
<?php
$sqlPubLocation = "SELECT DISTINCT location FROM `nmc_publisher` ORDER BY
pubName Asc";
$rsPubLocation = mysql_query($sqlPubLocation);
echo "<div id=\"PubLocation\">
Search by Location: <select name=\"pLocation\">
<option value=\"#\"></option>";
while ($row = mysql_fetch_assoc($rsPubLocation)) {
$location = $row['location'];
echo "<option value=\"$location\">$location</option>";
}
echo "</select></div>";
?>
<br /><br />
<input type="submit" name="submit"></input>
<input type="reset" name="reset"></input>
</form>
</div><!--end top-search-bar div-->
<hr />
<?php
// get each attribute value from the request stream
if(isset($_GET["search"])){
$search = $_GET['search'];
} else {
null;
}
if(isset($_GET["searchCDID"])){
$searchCDID = $_GET['searchCDID'];
} else {
null;
}
if(isset($_GET["searchPubID"])){
$searchPubID = $_GET['searchPubID'];
} else {
null;
}
if(isset($_GET["searchCatID"])){
$searchCatID = $_GET['searchCatID'];
} else {
null;
}
if(isset($_GET["price"])){
$price = $_GET['price'];
} else {
null;
}
if(isset($_GET["$catDesc"])){
$catDesc = $_GET['$catDesc'];
} else {
null;
}
if(isset($_GET["$CDYear"])){
$CDYear = $_GET['$CDYear'];
} else {
null;
}
if(isset($_GET["$pubName"])){
$pubName = $_GET['$pubName'];
} else {
null;
}
if(isset($_GET["$location"])){
$location = $_GET['$location'];
} else {
null;
}
//sql to show everything
$sql = "SELECT nmc_cd.CDID, nmc_cd.CDTitle, nmc_cd.CDYear,
nmc_cd.CDPrice, nmc_cd.pubID, nmc_cd.catID, nmc_publisher.pubName,
nmc_publisher.location, nmc_category.catDesc
FROM nmc_cd
INNER JOIN nmc_publisher ON nmc_cd.pubID = nmc_publisher.pubID
INNER JOIN nmc_category ON nmc_cd.catID = nmc_category.catID
WHERE 1
ORDER BY nmc_cd.CDTitle";
// make an empty string that will become the AND parts of the
query
// if any values were entered in the search form
$sqlCondition = "";
if($search=1){
$sqlCondition = $sqlCondition + "SELECT nmc_cd.CDID,
nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_cd.pubID, nmc_cd.catID,
nmc_publisher.pubName, nmc_publisher.location, nmc_category.catDesc
FROM nmc_cd
INNER JOIN nmc_publisher ON nmc_cd.pubID = nmc_publisher.pubID
INNER JOIN nmc_category ON nmc_cd.catID = nmc_category.catID
WHERE 1 AND CDTitle LIKE '%$search%'
ORDER BY nmc_cd.CDTitle";
}
if($searchCDID=1){
$sqlCondition = $sqlCondition + "SELECT nmc_cd.CDID,
nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_cd.pubID, nmc_cd.catID,
nmc_publisher.pubName, nmc_publisher.location, nmc_category.catDesc
FROM nmc_cd
INNER JOIN nmc_publisher ON nmc_cd.pubID = nmc_publisher.pubID
INNER JOIN nmc_category ON nmc_cd.catID = nmc_category.catID
WHERE 1 AND CDID LIKE '%$searchCDID%'
ORDER BY nmc_cd.CDTitle";
}
if($searchPubID=1){
$sqlCondition = $sqlCondition + "SELECT nmc_cd.CDID,
nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_cd.pubID, nmc_cd.catID,
nmc_publisher.pubName, nmc_publisher.location, nmc_category.catDesc
FROM nmc_cd
INNER JOIN nmc_publisher ON nmc_cd.pubID = nmc_publisher.pubID
INNER JOIN nmc_category ON nmc_cd.catID = nmc_category.catID
WHERE 1 AND pubID LIKE '%$searchPubID%'
ORDER BY nmc_cd.CDTitle";
}
if($pubName=1){
$sqlCondition = $sqlCondition + "SELECT nmc_cd.CDID,
nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_cd.pubID, nmc_cd.catID,
nmc_publisher.pubName, nmc_publisher.location, nmc_category.catDesc
FROM nmc_cd
INNER JOIN nmc_publisher ON nmc_cd.pubID = nmc_publisher.pubID
INNER JOIN nmc_category ON nmc_cd.catID = nmc_category.catID
WHERE 1 AND pubName LIKE '%$pubName%'
ORDER BY nmc_cd.CDTitle";
}
if($location=1){
$sqlCondition = $sqlCondition + "SELECT nmc_cd.CDID,
nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_cd.pubID, nmc_cd.catID,
nmc_publisher.pubName, nmc_publisher.location, nmc_category.catDesc
FROM nmc_cd
INNER JOIN nmc_publisher ON nmc_cd.pubID = nmc_publisher.pubID
INNER JOIN nmc_category ON nmc_cd.catID = nmc_category.catID
WHERE 1 AND location LIKE '%$location%'
ORDER BY nmc_cd.CDTitle";
}
if($price=1){
$sqlCondition = $sqlCondition + "SELECT nmc_cd.CDID,
nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_cd.pubID, nmc_cd.catID,
nmc_publisher.pubName, nmc_publisher.location, nmc_category.catDesc
FROM nmc_cd
INNER JOIN nmc_publisher ON nmc_cd.pubID = nmc_publisher.pubID
INNER JOIN nmc_category ON nmc_cd.catID = nmc_category.catID
WHERE 1 AND CDPrice LIKE '%$price%'
ORDER BY nmc_cd.CDTitle";
}
if($catDesc=1){
$sqlCondition = $sqlCondition + "SELECT nmc_cd.CDID,
nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_cd.pubID, nmc_cd.catID,
nmc_publisher.pubName, nmc_publisher.location, nmc_category.catDesc
FROM nmc_cd
INNER JOIN nmc_publisher ON nmc_cd.pubID = nmc_publisher.pubID
INNER JOIN nmc_category ON nmc_cd.catID = nmc_category.catID
WHERE 1 AND catDesc LIKE '%$catDesc%'
ORDER BY nmc_cd.CDTitle";
}
if($CDYear=1){
$sqlCondition = $sqlCondition + "SELECT nmc_cd.CDID,
nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_cd.pubID, nmc_cd.catID,
nmc_publisher.pubName, nmc_publisher.location, nmc_category.catDesc
FROM nmc_cd
INNER JOIN nmc_publisher ON nmc_cd.pubID = nmc_publisher.pubID
INNER JOIN nmc_category ON nmc_cd.catID = nmc_category.catID
WHERE 1 AND CDYear LIKE '%$CDYear%'
ORDER BY nmc_cd.CDTitle";
}
if($searchCDID=1){
$sqlCondition = $sqlCondition + "SELECT nmc_cd.CDID,
nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_cd.pubID, nmc_cd.catID,
nmc_publisher.pubName, nmc_publisher.location, nmc_category.catDesc
FROM nmc_cd
INNER JOIN nmc_publisher ON nmc_cd.pubID = nmc_publisher.pubID
INNER JOIN nmc_category ON nmc_cd.catID = nmc_category.catID
WHERE 1 AND CDID LIKE '%$searchCDID%'
ORDER BY nmc_cd.CDTitle";
}
$sqlSearch = $sql + $sqlCondition;
$rsSearch = mysql_query($sqlSearch);
echo "<div>";
while($row = mysql_fetch_assoc($rsSearch)){
$CDID = $row['CDID'];
$CDTitle = $row['CDTitle'];
$CDYear = $row['CDYear'];
$CDPrice = $row['CDPrice'];
$pubID = $row['pubID'];
$catID = $row['catID'];
$pubName = $row['pubName'];
$location = $row['location'];
$catDesc = $row['catDesc'];
echo "
<div class=\"title\"><h4><a
href='cd-description.php?cd=$CDID'>$CDTitle</a></h4></div>
<table class=\"searchtable\">
<tr>
<td>Year of Release: <strong>$CDYear</strong><br /></td>
<td>Price: <strong>£$CDPrice</strong><br /></td>
</tr>
<tr>
<td>Location: <strong>$location</strong><br /></td>
<td>Category: <strong>$catDesc</strong><br /></td>
</tr>
</table><hr />
</div>";
}
echo "</div>";
?>
</div><!--end article div-->
<div id="footer">
<div id="left-footer">
<img src="images/LogoFade.gif" alt="" />
</div><!--end left-footer div-->
<div id="validator">
<a href="http://validator.w3.org/check?uri=referer"
onclick="window.open(this.href,'_blank');return false;"><img
src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict"
height="31" width="88" /></a>
<a href="http://jigsaw.w3.org/css-validator/check/referer"
onclick="window.open(this.href,'_blank');return false;"><img
style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /></a>
</div><!--end validator div-->
</div><!--end footer div-->
</div><!--end main-body div-->
</div><!--end container div-->
</body>
</html>[/code]
Thanks for looking,
Jonathan
--- End Message ---