PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 3rd, 2013, 03:33 AM
chrismarsden chrismarsden is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 25 chrismarsden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 36 m 44 sec
Reputation Power: 0
Php and html inside a php array

Hi guys,

tried to google for this problem but cant seem to find the right answer.

I have a PHP array which i want to place html inside of, this html also has to php echos to get variables set by the database.

I can get the html to output perfectly fine, the php however comes up as text inside that.

any ideas or solutions welcome.

PHP Code:
<?php
$html 
= array
(
'<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="T9AKEUD6E">
<table>
<tr><td><input type="hidden" name="on0" value="Morgan Knightley Referance Num">Morgan Knightley Referance Number</td></tr><tr><td><input type="text" name="os0" maxlength="200"  value="<?php echo $MKREF.""; ?>"></td></tr>
<tr><td><input type="hidden" name="on1" value="SiP Referance Number">SiP Referance Number</td></tr><tr><td><input type="text" name="os1" maxlength="200"  value="<?php echo $row[1]; ?>"></td></tr>
</table>
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_paynow_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online."></form>' 
'75 pound box goes here when problem fixed');
?>
        <?php
if ( $row[3] = "50.00" ) {
    echo 
$html[0];
} else {
    echo 
$html[1];
}        
?>

Reply With Quote
  #2  
Old January 3rd, 2013, 04:09 AM
sir_drinxalot's Avatar
sir_drinxalot sir_drinxalot is offline
Known to taste like chicken
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: In front of my computer
Posts: 377 sir_drinxalot User rank is Captain (20000 - 30000 Reputation Level)sir_drinxalot User rank is Captain (20000 - 30000 Reputation Level)sir_drinxalot User rank is Captain (20000 - 30000 Reputation Level)sir_drinxalot User rank is Captain (20000 - 30000 Reputation Level)sir_drinxalot User rank is Captain (20000 - 30000 Reputation Level)sir_drinxalot User rank is Captain (20000 - 30000 Reputation Level)sir_drinxalot User rank is Captain (20000 - 30000 Reputation Level)sir_drinxalot User rank is Captain (20000 - 30000 Reputation Level)sir_drinxalot User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 3 h 27 m 44 sec
Reputation Power: 293
Send a message via MSN to sir_drinxalot
php's eval construct might be what you want, BUT, it comes with a some risks.

You could also flesh out your string before you store it in the array, or look into another way of doing it.

I would skip the array all together unless you absolutely positively have to have it, and just form the data if / when it is needed:

PHP Code:
<?php 
if ( $row[3] = "50.00" ) { 
    echo 
"<form action...value=\"".$MKREF."\"></td>...value=\"".$row[1]."\"></td>...</form>"
} else { 
    echo 
"75 pound etc etc..."
}         
?>


that way you're only ever dealing with data you're going to use, and not processing variables which will never impact on the output etc.
__________________
"Take thy beak from out my heart, and take thy form from off my door" - Homer J Simpson / Edgar Allan Poe

Looking for a project Idea?

Reply With Quote
  #3  
Old January 3rd, 2013, 04:33 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,864 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 21 h 21 m 12 sec
Reputation Power: 813
Hi,

what exactly are you trying to do with the array? This approach looks very obscure (as sir_drinxalot already said), and I'm pretty sure there's a sane solution for the original problem.

Reply With Quote
  #4  
Old January 3rd, 2013, 06:29 AM
chrismarsden chrismarsden is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 25 chrismarsden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 36 m 44 sec
Reputation Power: 0
basicly i was after checking an amount in the database, based on this amount output 1 of 2 payment option buttons.

I have now fixed my original problem with a helping hand from the post sir_drinxalot made.

PHP Code:
<?php
if ( $row[3] >= "50.00" ) {
    echo 
"Thank you   <b>\"".$row[0]."\",</b> <br>
        You have chosen to pay for your ticket and qualify for the discount, this is related to your car registration number: <b>\""
.$row[2]."\"</b><br><br>
        <b>Details of Offence</b><br>
        Offence Date: \""
.date("d/m/Y"strtotime $row[8] ) )."\"<br>
        Offence Time: \""
.$row[9]."\"<br>
        Offence Committed: \""
.$row[7]."\"<br>
        <b>Your Details</b><br>
        Your Address:\""
.$row[4]."\",\"".$row[5]."\",\"".$row[6]."\"<br><br>
    <br></p>"
;
} else {
    echo         
"<b></b>";
}        
?>


now the problem im getting is this. the output information appears as "persons name" with the "" surrounding all the database text.

how can i strip these?

Reply With Quote
  #5  
Old January 3rd, 2013, 06:58 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,864 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 21 h 21 m 12 sec
Reputation Power: 813
Quote:
Originally Posted by chrismarsden
how can i strip these?


Um, by leaving them out? Each \" yields a double quote in your output.

Reply With Quote
  #6  
Old January 3rd, 2013, 07:38 AM
chrismarsden chrismarsden is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 25 chrismarsden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 36 m 44 sec
Reputation Power: 0
its always the simple answers that escape me lol

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Php and html inside a php array

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap