Solved

How can i modify this custom function in php?

Posted on 2016-07-31
5
46 Views
Last Modified: 2016-08-04
Hello;

I have this function and it works

<?php
        $tab  = "<div class='articletitle'>";
          $tab .= "<a href='./$folder/$file?articleid=$articleid&parentid=$parentid&catid=$catid'><strong>$title$audioicon 
		   </strong></a></div>";
          $tab .= "<div class='mimage'>";
          $tab .= "<a href='./$folder/$file?articleid=$articleid&parentid=$parentid&catid=$catid'>
		   <img src='./images/mimage/$photo' border='0' alt='$altdescription' /></a><br/>";	  
          $tab .= "<span class='span_class'>$description1...  </span></div><hr class='hr95'>";
          return $tab;
		  
          }
          $tab = "";
 ?>

Open in new window


But i want change it to have one <div> with 3 raws(one for Title,one for image,and one for title description) as below,appreciate that let me know is it possible and how?
Because when i want apply 'float' i can.

    <div class="wrapper">
  <div class="row1">for title</div>
  <div class="row2">for image</div>
  <div class="row3">for small description</div>
</div>

Open in new window

0
Comment
Question by:MOSTAGHASSI
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 41736652
This appears to be missing the function signature line, so there may be other things missing, too.  But that said, you can return any string variable you want from a PHP function, like this.
https://iconoun.com/demo/temp_mosta.php
<?php // demo/temp_mosta.php
/**
 * https://www.experts-exchange.com/questions/28960612/How-can-i-modify-this-custom-function-in-php.html
 *
 * http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
 */
error_reporting(E_ALL);

function mosta()
{
    // CREATE A RETURN STRING IN HEREDOC NOTATION
    $tab = <<<EOD
    <div class="wrapper">
      <div class="row1">for title</div>
      <div class="row2">for image</div>
      <div class="row3">for small description</div>
    </div>
EOD;

    return $tab;
}


// CALL THE FUNCTION
$new = mosta();

// SHOW THE WORK PRODUCT
echo '<pre>';
echo htmlentities($new);

Open in new window

If you're new to PHP and want to find some good learning resources, this article can help.
https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html
0
 

Author Comment

by:MOSTAGHASSI
ID: 41736728
Hi Ray,thanks and sorry, yes you are right,for those missing,it works well and as usual your solution is professional.

In addition i have another question(tomorrow send on experts-exchange)  regarding the call of this function to my program,how can i  access you for that?

Thanks for your article also.
1
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 41736809
If you post the question in the PHP Zone I will almost certainly see it!

Thanks for the points and thanks for using E-E, ~Ray
0
 

Author Comment

by:MOSTAGHASSI
ID: 41741935
Hi Ray;
Is it possible for you that have a look on this question/thanks:



This question is regarding the calling of function that you solve it above:
function mosta()
{
    // CREATE A RETURN STRING IN HEREDOC NOTATION
    $tab = <<<EOD
    <div class="wrapper">
      <div class="row1">for title</div>
      <div class="row2">for image</div>
      <div class="row3">for small description</div>
    </div>
EOD;

    return $tab;
}

Open in new window


I want call this function so arrange it  in 2 columns and 4 rows as:

block1      block2

block3      block4

block5      block6

block7      block8

each block is calling the function with new data,something like this below(it call 8 times the function but not arrange right) that don't arrange in div that the calling happen:
-function doArticle_image300_artandculture() is the mosta() function.
-The codes below is just for the things that is in my mind,and want to show what i want.

$result_artandculture = mysql_query($query_artandculture);

if ( $result_artandculture) {
	
	      $i = 1;
     for ( $i=1 ; $i<=4; $i++){
    $rw = @mysql_fetch_assoc( $result_artandculture);
    $new= doArticle_image300_artandculture( $rw['articleid'], $rw['title'], $rw['description1'], $rw['photofilename'], $rw['parentid'], $rw['catid'],$rw['mediastate'],$rw['altdescription']); 
	 echo "$new";
	 
	 if ( $rw = @mysql_fetch_assoc($result_artandculture ) )

 	 $new=doArticle_image300_artandculture( $rw['articleid'], $rw['title'], $rw['description1'], $rw['photofilename'],       $rw['parentid'], $rw['catid'],$rw['mediastate'],$rw['altdescription']);
		 
		 
		echo "$new";
	 
	 
     }
	
	} 

Open in new window

0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question