Note that there are some explanatory texts on larger screens.

plurals
  1. POList images from directory by function
    text
    copied!<p>I'm using this function:</p> <pre><code>function getmyimages($qid){ $imgdir = 'modules/Projects/uploaded_project_images/'. $qid .''; // the directory, where your images are stored $allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show $dimg = opendir($imgdir); while($imgfile = readdir($dimg)) { if(in_array(strtolower(substr($imgfile,-3)),$allowed_types)) { $a_img[] = $imgfile; sort($a_img); reset ($a_img); } } $totimg = count($a_img); // total image number for($x=0; $x &lt; $totimg; $x++) { $size = getimagesize($imgdir.'/'.$a_img[$x]); // do whatever $halfwidth = ceil($size[0]/2); $halfheight = ceil($size[1]/2); $mytest = 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'&lt;br /&gt;&lt;a href="'. $imgdir .'/'.$a_img[$x].'"&gt;'. $a_img[$x]. '&lt;/a&gt;'; } return $mytest; } </code></pre> <p>And I call this function between a <code>while</code> row as:</p> <pre><code>$sql_select = $db-&gt;sql_query('SELECT * from '.$prefix.'_projects WHERE topic=\''.$cid.'\''); OpenTable(); while ($row2 = $db-&gt;sql_fetchrow($sql_select)){ $qid = $row2['qid']; $project_query = $db-&gt;sql_query('SELECT p.uid, p.uname, p.subject, p.story, p.storyext, p.date, p.topic, p.pdate, p.materials, p.bidoptions, p.projectduration, pd.id_duration, pm.material_id, pbo.bidid, pc.cid FROM ' . $prefix . '_projects p, ' . $prefix . '_projects_duration pd, ' . $prefix . '_project_materials pm, ' . $prefix . '_project_bid_options pbo, ' . $prefix . '_project_categories pc WHERE p.topic=\''.$cid.'\' and p.qid=\''.$qid.'\' and p.bidoptions=pbo.bidid and p.materials=pm.material_id and p.projectduration=pd.id_duration'); while ($project_row = $db-&gt;sql_fetchrow($project_query)) { //$qid = $project_row['qid']; $uid = $project_row['uid']; $uname = $project_row['uname']; $subject = $project_row['subject']; $story = $project_row['story']; $storyext = $project_row['storyext']; $date = $project_row['date']; $topic = $project_row['topic']; $pdate = $project_row['pdate']; $materials = $project_row['materials']; $bidoptions = $project_row['bidoptions']; $projectduration = $project_row['projectduration']; //Get the topic name $topic_query = $db-&gt;sql_query('SELECT cid,title from '.$prefix.'_project_categories WHERE cid =\''.$cid.'\''); while ($topic_row = $db-&gt;sql_fetchrow($topic_query)) { $topic_id = $topic_row['cid']; $topic_title = $topic_row['title']; } //Get the material text $material_query = $db-&gt;sql_query('SELECT material_id,material_name from '.$prefix.'_project_materials WHERE material_id =\''.$materials.'\''); while ($material_row = $db-&gt;sql_fetchrow($material_query)) { $material_id = $material_row['material_id']; $material_name = $material_row['material_name']; } //Get the bid methode $bid_query = $db-&gt;sql_query('SELECT bidid,bidname from '.$prefix.'_project_bid_options WHERE bidid =\''.$bidoptions.'\''); while ($bid_row = $db-&gt;sql_fetchrow($bid_query)) { $bidid = $bid_row['bidid']; $bidname = $bid_row['bidname']; } //Get the project duration $duration_query = $db-&gt;sql_query('SELECT id_duration,duration_value,duration_alias from '.$prefix.'_projects_duration WHERE id_duration =\''.$projectduration.'\''); while ($duration_row = $db-&gt;sql_fetchrow($duration_query)) { $id_duration = $duration_row['id_duration']; $duration_value = $duration_row['duration_value']; $duration_alias = $duration_row['duration_alias']; } } echo '&lt;br/&gt;&lt;b&gt;id&lt;/b&gt;---&gt;' .$qid. '&lt;br/&gt;&lt;b&gt;uid&lt;/b&gt;---&gt;' .$uid. '&lt;br/&gt;&lt;b&gt;username&lt;/b&gt;---&gt;' .$uname. '&lt;br/&gt;&lt;b&gt;subject&lt;/b&gt;---&gt;'.$subject. '&lt;br/&gt;&lt;b&gt;story1&lt;/b&gt;---&gt;'.$story. '&lt;br/&gt;&lt;b&gt;story2&lt;/b&gt;---&gt;'.$storyext. '&lt;br/&gt;&lt;b&gt;postdate&lt;/b&gt;---&gt;'.$date. '&lt;br/&gt;&lt;b&gt;categorie&lt;/b&gt;---&gt;'.$topic_title . '&lt;br/&gt;&lt;b&gt;project start&lt;/b&gt;---&gt;'.$pdate. '&lt;br/&gt;&lt;b&gt;materials&lt;/b&gt;---&gt;'.$material_name. '&lt;br/&gt;&lt;b&gt;bid methode&lt;/b&gt;---&gt;'.$bidname. '&lt;br/&gt;&lt;b&gt;project duration&lt;/b&gt;---&gt;'.$duration_alias.'&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;b&gt;image url&lt;/b&gt;---&gt;'.getmyimages($qid).'&lt;br /&gt;&lt;br /&gt;'; } CloseTable(); </code></pre> <p>The result outputs only the "last" file from the directories. If I do an <code>echo</code> instead of a <code>return $mytest;</code>, it reads the whole directory but ruins the output.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload