3 Replies - 1246 Views - Last Post: 05 July 2010 - 04:30 AM Rate Topic: -----

#1 Senseye  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 65
  • Joined: 02-March 09

PHP CODE into PRINTF

Posted 05 July 2010 - 02:56 AM

Hello again!

There is a problem to me again... How can I insert a php code into printf procedure...


printf("<div id='pmbox1'>
<p>From <a href='userdetails.php?id=%s'>%s</a> on <strong>%s</strong>//////Right there I need to insert an IF; How can I do this?\\\\\\</p>

	 <div>
	 %s
	 </div>
	 <br>
	 <a href='deletemessage.php?id=%s'>Delete</a>
	 </div>
	 ",$myrow4['id'],$author,$messages['date'],$messages['text'],$messages['id']);



Is This A Good Question/Topic? 0
  • +

Replies To: PHP CODE into PRINTF

#2 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: PHP CODE into PRINTF

Posted 05 July 2010 - 03:05 AM

Well, you could do multiple printf calls, breaking for when you need to do other things, such as if statements and other logic and conditionals. That'd be the easiest way. There are a multitude of ways though.

A really good alternative would be using a template engine such as Smarty which supports if statements in its template files.
Was This Post Helpful? 1
  • +
  • -

#3 Senseye  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 65
  • Joined: 02-March 09

Re: PHP CODE into PRINTF

Posted 05 July 2010 - 04:29 AM

Valek, Thank you again for advice!
Was This Post Helpful? 0
  • +
  • -

#4 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: PHP CODE into PRINTF

Posted 05 July 2010 - 04:30 AM

Glad to help, as always :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1