|
Hello all,
In a piece of PHP code, I'm trying to set two styles at the same time for a set of dynamically created divs...
The code I'm trying to use is:
echo('<div id="'.$DivId.'" style=width:'.$width.'; display:none>;');
As you can see $DivId is a variable that depends on a loop.
I need to set the width (another parameter).
And at the beginning that DIV must be not shown hence the display:none.
If I try to modify the style one at a time it works well... I mean that if I try to change the width only or the display only it works well... but I don't know how to chain the two changes.
Any advice?
Thank you in advance!
PS: I've tried to Google for "php more than one style", "php change styles", "php style guide"... no luck here...
|
|
|
|
|
I tried the solution in the third link and all the solutions that Graham is proposing and none of them worked...
Somehow a problem must be there that doesn't allow it to work... it is like the display:none modifier that I'm adding would avoid anything else to work...
Thank you for trying!
|
|
|
|
|
I've found the problem...
It happens that the TinyMCE editor window that I'm using in that place doesn't override the style when using display:none in the div that it is contained...
AMAZING.
Well, I've found that this has happened to lots of people and a trick to cheat that...
It is a PITA when you put efforts and time to solve things that should be working ok...
Many thanks for helping me.
|
|
|
|
|
It looks like you're not quoting the style, so the attribute is being broken on the space in the middle - try this:
echo('<div id="'.$DivId.'" style="width:'.$width.'; display:none>;"');
or this:
echo('<div id="'.$DivId.'" style=width:'.$width.';display:none>;');
|
|
|
|
|
Using the first option (quoted) the width is applied but the display:none is not.
Using the second of those options (no space) the width is not being modified and only display:none works.
PS: it is like if the display:none would destroy all the other options out there...
Thank you for trying...
|
|
|
|
|
That sounds very odd... What is the value of $width ?
|
|
|
|
|
I've used 1000 and "100%" without luck... with both numbers removing the display:none it works like charm...
|
|
|
|
|
CSS values should really have specified units, though the browser will assume pixels if you leave it off - make sure that the generated source looks something like this:
<div id="div0001" style="width:1000px; display:none"> ...content... </div>
or for percentage:
<div id="div0001" style="width:100%; display:none"> ...content... </div>
If this fails to work, then I suspect the problem is somewhere else in the CSS and the DIV is picking up rules from the stylesheet.
|
|
|
|
|
No luck... the syntax is exactly the one you are specifying here... and it does not work... I've put strange id's like "grahambreachishelpingme" (and I'm sure that I don't have any id like this one in any CSS file out there)...
Any other idea?
Anyway thank you again for trying...
|
|
|
|
|
Without being able to see the full page, I'm a bit short of ideas.
If I could see the page, I would inspect the DIV using FireBug in Firefox, or Chrome's developer tools. That way you can see which styles are being applied to it and where they are coming from.
|
|
|
|
|
I've found the problem...
It happens that the TinyMCE editor window that I'm using in that place doesn't override the style when using display:none in the div that it is contained...
AMAZING.
Well, I've found that this has happened to lots of people and a trick to cheat that...
It is a PITA when you put efforts and time to solve things that should be working ok...
Many thanks for helping me.
|
|
|
|
|
I'm trying to implement a simple tracking ID in my Wordpress theme. It would work like this, I put links out on the internet including a get parameter as follows:
http://www.mywebsite.com?track_id=myid
When visitor travels to my site through the link it latches the track_id as they click through the site and doesn't release the id until they leave.
At any given point in the visitor's session I want to look up which affiliate referred them to my site so if the visitor buys anything I can track my sales and which traffic sources and or affiliates are working out the best.
It seems pretty simple but I cannot figure out how to latch the tracking ID to a visitors session on the site.... Anybody know???
Thanks!!!!
|
|
|
|
|
Would simply using PHP's built-in session handling be sufficient for your purposes?
see, e.g., http://www.tizag.com/phpT/phpsessions.php[^]
If not, let me know exactly why not and maybe we can come up with an alternative idea.
--Greg
|
|
|
|
|
You could use a session cookie then retrieve the value from $_COOKIE as they move thru the site.
|
|
|
|
|
Whenever i try to integrate Php with Apache using genuine pattern of copying php.ini-development file
changing path i encounter a problem ie when i restart my apache server it pops a error message and does not start again .Please someone help me with this problem.
|
|
|
|
|
I shoul you to use XAMPP ... it's very usefull for your purpose !
Check it here
www.malorgio.it
|
|
|
|
|
Hi,
I m totally new for PHP.
I downloaded one data grid example from sigmawidgets.com mostly pages are running well but some pages have PHP code which is not running, because I have not installed the PHP on that server.
I have Apache Tomcat (5.28...) web server on 64bit Windows 2000 server.
Can some help me how to install PHP and how it works.
Thanks in advance.
|
|
|
|
|
You may wish to try XAMPP.
It's available in an installer package that will setup the whole suite - php, mysql, apache etc.
It comes with a number of examples of php code.
|
|
|
|
|
You can also check the EasyPHP suite which is more or less the same than XAMPP.
Good luck
|
|
|
|
|
I have a string variable $xml which contains this string:
<rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:sumo="http://www.ontologyportal.org/translations/SUMO.owl.txt#" xmlns:dul="http://www.loa-cnr.it/ontologies/DUL.owl" xmlns:owl="http://www.w3.org/2002/07/owl" xmlns:top="http://talkingowlproject.com/schemas/top-level-concepts-10/" xmlns:wps="http://talkingowlproject.com/schemas/wordnet-parser-schema-10/"><rdf:Description rdf:id="#me">
<rdfs:label>Pigwidgeon</rdfs:label>
<rdf:type rdf:resource="http://talkingowlproject.com/schemas/top-level-concepts-10/TalkingOwl" />
</rdf:Description>
<rdf:Description rdf:id="#you">
<rdfs:label>greg</rdfs:label>
<rdf:type rdf:resource="http://talkingowlproject.com/schemas/top-level-concepts-10/User" />
</rdf:Description></rdf:rdf>
I have the following code:
$xmlobj = simplexml_load_string($xml);
if ($xmlobj===false) die('bad news');
print_r($xmlobj);
The result displayed is (appears to be?) an empty structure:
SimpleXMLElement Object
(
)
And when I try to iterate over members of the object, it performs no iterations (confirming that the structure is empty).
Is there something wrong with the XML string? Is there a problem because of the namespace declarations or the use of namespaces on every tag? When I remove the namespace declarations in the root tag, I actually get a structure with contents .... but then it doesn't know the namespaces, so it can't use them when I'm parsing the object. (I need to be able to identify namespaces with nodes.)
Thank you for your help.
--Greg
|
|
|
|
|
I finally found out what was wrong, and came up with a solution!
I hope it isn't considered "bad form" to link to a blog post, but I wrote a long and involved blog explaining my frustration and what I found out the problem to be here:
http://talkingowlproject.blogspot.com/2011/06/simplexml-and-namespace-quirks.html[^]
And I actually wrote my own class, SimpleRDFElement , to extend the SimpleXMLElement class and solve the problems. You can read my description of my extension class and download the 1-page source code here:
http://talkingowlproject.blogspot.com/2011/06/simplerdfelement-class-extension-of.html[^]
In a nut shell: the built in functions with SimpleXML handle namespaces poorly, the children() and attributes() methods only allow you to select children and attributes in a particular namespace (not all at once), and there are no functions specifically for extracting the namespace portion of the tag of the current top-level element.
So, my extension class, SimpleRDFElement, provides functions to solve all of these problems, as well as a method for parsing an RDF XML string into triples.
I hope that this helps anyone else who is interested in this question!
|
|
|
|
|
Good one! Would you consider massaging your writeup into a tip/trick or article for CP? It's exactly the right kind of stuff.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Thanks for the suggestion! I've done it, and the article is now posted. Cheers!
--Greg
|
|
|
|
|
Hi,
I need to know what's wrong in this code that can't show any data using CURL -
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://search.msn.com/results.aspx?q=test&FORM=MSNH");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1=curl_exec($ch);
echo "<font color=black face=verdana size=3>".$data1."</font>";
echo curl_error($ch);
curl_close($ch);
?>
Nothing is showing ..
N.B.: My Curl is enabled.
modified on Monday, June 27, 2011 11:23 PM
|
|
|
|
|
Hi!
I'd like to know if there's a way I can call a javascript variable in a php function?
Like for example, the code below would get the value of textbox text1 when the button is clicked. It should call the javascript function with a parameter. That javascript function calls the PHP function with a javascript variable nVal.
<?php
Function ShowNumber($nValue) {
$nTotal = $nValue + 1;
Return $nTotal;
}
?>
<script language="javascript">
Fuction PassNumber(nVal) {
alert("<?php ShowNumber("+nVal+"); ?>");
}
</script>
<input type="text" name="text1" value="200" /><br />
<input type="button" value="Go" onClick="PassNumber(this.text1.value)" />
Thanks.
|
|
|
|