xml - Styling PHP very proving difficult -


i have form user type in there reference number check status of in enquiry:

example: user navigate webpage: http://www.cdreporting.co.uk/ajax/search2.html

they type in reference: "1" or "2" , "3" etc...whatever number allocated displays brief record.

but i'm unable format data displayed. wish have reference number diferrent colour, wish create line breaks, underline emails addresses. i'm unsure how current .php code

how edit each field such email? can change font etc..? "reference" field stated in php code:

   <?php    $q=$_get["q"];    $xmldoc = new domdocument();   $xmldoc->load("cd_catalog.xml");    $x=$xmldoc->getelementsbytagname('reference');    ($i=0; $i<=$x->length-1; $i++) {   //process element nodes   if ($x->item($i)->nodetype==1) {   if ($x->item($i)->childnodes->item(0)->nodevalue == $q) {   $y=($x->item($i)->parentnode);  }  }  }  $cd=($y->childnodes);  ($i=0;$i<$cd->length;$i++) { //process element nodes if ($cd->item($i)->nodetype==1) { echo("<b>" . $cd->item($i)->nodename . ":</b> "); echo($cd->item($i)->childnodes->item(0)->nodevalue); echo("<br>"); } } ?>  

the fields code currenty display:

reporter: test1 reference: 1 submission: 2014-11-08t00:00:00 status: pending officer: name1 email: test@email.com telephone: 0113 1234

also i'm notsure why reference uppercase either, know have attribute i'm unsure on how apply them php code dont know how reference each individual field.


big thank taking time help.

i have xml file: http://www.cdreporting.co.uk/ajax/cd_catalog.xml php refers to.

when time enters reference number data xml displayed. on xml there email field display differently i.e change of font colour. how within php code have? know can use css in php code apply email field?.

basically styling each field xml


wow manys thank yet again...unfortunatly confusing me. leaving css styling aside , going php code.

is possible php display each field within php e.g.

if ($cd->item($i)->nodetype==1) { echo("<b>" . $cd->item($i)->nodename . ":</b> "); if ($cd->item($i)->nodename == "**reference**") {     echo '<span class="reference">'.$cd->item($i)->childnodes->item(0)->nodevalue. '</span>'; } else {     echo($cd->item($i)->childnodes->item(0)->nodevalue); } echo("<br>");  if ($cd->item($i)->nodetype==1) { echo("<b>" . $cd->item($i)->nodename . ":</b> "); if ($cd->item($i)->nodename == "**reporter**") {     echo '<span class="reference">'.$cd->item($i)->childnodes->item(0)->nodevalue. '</span>'; } else {     echo($cd->item($i)->childnodes->item(0)->nodevalue); } echo("<br>");  if ($cd->item($i)->nodetype==1) { echo("<b>" . $cd->item($i)->nodename . ":</b> "); if ($cd->item($i)->nodename == "**submission**") {     echo '<span class="reference">'.$cd->item($i)->childnodes->item(0)->nodevalue. '</span>'; } else {     echo($cd->item($i)->childnodes->item(0)->nodevalue); } echo("<br>");  if ($cd->item($i)->nodetype==1) { echo("<b>" . $cd->item($i)->nodename . ":</b> "); if ($cd->item($i)->nodename == "**email**") {     echo '<span class="reference">'.$cd->item($i)->childnodes->item(0)->nodevalue. '</span>'; } else {     echo($cd->item($i)->childnodes->item(0)->nodevalue); } echo("<br>"); 

does above right? can edit each field change font or add line break?

you need css, similar this:

.reference {color: blue;} 

then revise php check node name being "reference" , emit necessary markup invoke css:

//process element nodes if ($cd->item($i)->nodetype==1) { echo("<b>" . $cd->item($i)->nodename . ":</b> "); if ($cd->item($i)->nodename == "reference") {     echo '<span class="reference">'.$cd->item($i)->childnodes->item(0)->nodevalue. '</span>'; } else {     echo($cd->item($i)->childnodes->item(0)->nodevalue); } echo("<br>"); 

you can style other fields (nodes) in same way, including line breaks , other formatting. php's switch operator if want style lot of them.

as far "reference" being uppercase, link shows it's in xml way. can use if statement emit "reference" if necessary, or correct what's getting stored in xml.

now i've thought bit, if name css styles same xml node names, can style every item pretty easily. make styles alike or different depending upon how write css.

   //process element nodes     if ($cd->item($i)->nodetype==1) {       $class = strtolower($cd->item($i)->nodename);       echo("<b>" . $cd->item($i)->nodename . ":</b> ");       echo "<span class=\"$class\">".$cd->item($i)->childnodes->item(0)->nodevalue. '</span>';       echo("<br>");    } 

this takes node name, forces lowercase using strtolower , assigns $class. <span> element uses $class class name. whatever you've written in css class name applied style.

you can apply same idea style name names, you'll need different class names. so, like: <span class=\"nn-$class\">" apply class nn-reference node name reference.

in cases may want use <div> rather <span> block-level formatting. you'll have decide , modify code accordingly.

note: haven't tested code above; i'd need xml that. there may small syntax errors, idea correct.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -