thesecretary.org / projectFirstThumb


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function projectFirstThumb($idslug){
  2. global $clerk;
  3.  
  4. // Only one row (because one id unique)
  5. $project = mysql_fetch_alias_array( $clerk->query_select( 'projects', '', 'WHERE projects.slug="'.$idslug.'"' ) );
  6. // Not found try by ID not slug
  7. if ($project=="") {
  8. $project = mysql_fetch_alias_array( $clerk->query_select( 'projects', '', 'WHERE projects.id="'.$idslug.'"' ) );
  9. }
  10.  
  11. if ($project['projects.thumbnail'] != '') {
  12. return PROJECTS_URL.$project['projects.slug'].'/'.$project['projects.thumbnail'];
  13. } else {
  14. $filesGet = $clerk->query_select( 'project_files', '', 'WHERE type="image" AND project_id='.$project['projects.id'].' ORDER BY filegroup,pos ASC LIMIT 1');
  15. while ( $file = mysql_fetch_alias_array($filesGet)) {
  16. return PROJECTS_URL.$project['projects.slug'].'/'.$file['project_files.thumbnail'];
  17. }
  18. }
  19. return '';
  20. }
  21.  
  22.  
  23.  
  24. function mysql_fetch_alias_array($result) {
  25. // Avoid the problem of duplicated field names in joint queries
  26. // From Post by Mehdi Haresi in PHP.net
  27. if (!($row = mysql_fetch_array($result))) {
  28. return null;
  29. }
  30.  
  31. $assoc = Array();
  32. $rowCount = mysql_num_fields($result);
  33.  
  34. for ($idx = 0; $idx < $rowCount; $idx++) {
  35. $table = mysql_field_table($result, $idx);
  36. $field = mysql_field_name($result, $idx);
  37. $assoc["$table.$field"] = $row[$idx];
  38. }
  39. return $assoc;
  40. }

URL: http://www.thesecretary.org/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.