help

Discussion in 'PHP' started by paffbg, Nov 20, 2010.

  1. #1
    Hello,
    how can do <? $a = <font id="e9"></font>; ?>
     
    paffbg, Nov 20, 2010 IP
  2. tobydawson13

    tobydawson13 Active Member

    Messages:
    645
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Maybe <? $a = "<font id=\"e9\"></font>"; ?>
     
    tobydawson13, Nov 20, 2010 IP
  3. CPAPubMichael

    CPAPubMichael Peon

    Messages:
    231
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try this:

    
    
     <?php
    
        $a = "<font id='e9'></font>";
    
     ?>
    
    
    PHP:
    or if you are doing error messages you can do this

    
    
     <?php
    
       $aOpen = "<font id='e9'>";
       $aClose = "</font>";
    
     ?>
    
    
    PHP:
    Then just echo out your message, here is an example.

    
    
     <?php
    
       $aOpen = "<font id='e9'>";
       $aClose = "</font>";
    
         echo $eOpen . "Here is the information you are echoing out." . $eClose;
    
     ?>
    
    
    PHP:
    I hope i helped.
     
    CPAPubMichael, Nov 20, 2010 IP
  4. paffbg

    paffbg Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The is number "<font id='e9'></font>" extract from JS.
    I want this number = $a so I can $a > 0, $a < 0.......
     
    paffbg, Nov 20, 2010 IP
  5. paffbg

    paffbg Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The is my full code, file t.php.
    <font id='p7'></font> comes from JS and a number.
    how to enroll in Mysql number of <font id='p7'></font>



    <form action="t.php" method="post" id="settingsForm" name="settingsForm">
    <input type="hidden" name="special_discount" id="special_discount" value="0" />



    <p><label>
    <input type="radio" name="vip" value="2" id="v" onclick="calcadv" />1 </br>
    <input type="radio" name="vip" value="3 id="v" onclick="calcadv" />2</br>
    </label></p>




    <p><label>
    <input type="radio" name="week" value="2" id="w" onclick="calcadv" /> 1 </br>
    <input type="radio" name="week" value="3" id="w" onclick="calcadv" /> 2</br>
    </label></p>

    <p><label>

    Total: <font id='p7'></font>

    </label></p>





    <p>
    <input class="button" type="submit" value="Изпрати" name=saveu />
    </p>


    </form>
     
    paffbg, Nov 20, 2010 IP
  6. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Your question is unintelligible. I'll take a stab at it anyway, is this what you're talking about?

    
    <?php
        $html = "<font id='e9'></font>";
        preg_match("/<font\sid='.(\d+)'/i", $html, $matches);
        $a = $matches[1];
    
        // you now have $a to play with..
        echo $a;
    ?>
    
    PHP:
     
    Deacalion, Nov 20, 2010 IP
  7. paffbg

    paffbg Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Sorry for my bad English.
    How do I change the code to be recorded in the mysql result of total






    <form action="t.php" method="post" id="settingsForm" name="settingsForm">
    <input type="hidden" name="special_discount" id="special_discount" value="0" />



    <p><label>
    <input type="radio" name="vip" value="2" id="v" onclick="calcadv" />1 </br>
    <input type="radio" name="vip" value="3 id="v" onclick="calcadv" />2</br>
    </label></p>




    <p><label>
    <input type="radio" name="week" value="2" id="w" onclick="calcadv" /> 1 </br>
    <input type="radio" name="week" value="3" id="w" onclick="calcadv" /> 2</br>
    </label></p>

    <p><label>

    Total: <font id='p7'></font> //////////// <- this result I want to save in mysql !!!!!!!!!!!!!!!!!!!!! ////////////////

    </label></p>





    <p>
    <input class="button" type="submit" value="Изпрати" name=saveu />
    </p>


    </form>
     
    Last edited: Nov 20, 2010
    paffbg, Nov 20, 2010 IP
  8. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Ahh, ok. I think I understand now. :)

    In order to pass data to the PHP script (and subsequently MySQL), you will either have to create a form and have your JavaScript events change the value of one of the fields (this could even be a hidden field) or create an Ajax call that passes everything to the script.

    So, here is the example HTML:
    
    <form action="t.php" method="post" id="settingsForm" name="settingsForm"> 
    	<input type="hidden" name="special_discount" id="special_discount" value="0" /> 
    
    	<p>
    		<label> 
    			<input type="radio" name="vip" value="2" id="v" onclick="calcadv()" />1 </br> 
    			<input type="radio" name="vip" value="3 id="v" onclick="calcadv()" />2</br> 
    		</label>
    	</p> 
    
    	<p>
    		<label> 
    			<input type="radio" name="week" value="2" id="w" onclick="calcadv()" /> 1 </br> 
    			<input type="radio" name="week" value="3" id="w" onclick="calcadv()" /> 2</br> 
    		</label>
    	</p> 
    
    	<p>
    		<label>
    			<!-- This field has been added -->
    			<input type="hidden" name="result" id="result" />
    			Total: <font id='p7'></font>
    		</label>
    	</p> 
    
    	<p> 
    		<input class="button" type="submit" value="Изпрати" name=saveu /> 
    	</p> 
    </form>
    
    HTML:
    Now the JavaScript function you use to to calculate the result would also put said result in the hidden field:
    
    function calcadv() {
    	// All of your code here...
    	
    	// assuming 'result' is the right variable
    	document.getElementById("result").value = result;
    }
    
    Code (markup):
    And finally, in PHP you could see this by looking at $_POST['result'].
     
    Deacalion, Nov 21, 2010 IP
  9. paffbg

    paffbg Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Not work :(
    Can a $ _POST take info from <div or <span ?
    example
    <div id='p7' name="result" ></div>
    $as = $_POST['result']
     
    paffbg, Nov 21, 2010 IP
  10. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #10
    No, it has to be a form field. Which can either be <input> or <textarea>.
     
    Deacalion, Nov 21, 2010 IP