Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To get linked titles you need to use the <code>l()</code> function.</p> <p>looking at the code you provided, I am not entirely sure how you are getting any results since you save the titles in <code>$resultArray</code> but use <code>$rows</code> when rendering the table.</p> <p>Unless, $rows is specified somewhere else, <code>$resultarray[$nodeobj-&gt;nid] = $nodeobj-&gt;title;</code> should become <code>$rows[$nodeobj-&gt;nid] = $nodeobj-&gt;title;</code> To make it match your table header, you need to add another 'cell' for the number column</p> <pre><code>$rows[$nodeobj-&gt;nid] = array( $count++, l($nodeobj-&gt;title, 'node/'.$nodeobj-&gt;nid) ); </code></pre> <p>To provide the excerpt too, you need to join the node_revisions table and get either the body or teaser column, then add it to your rows like this:</p> <pre><code>$rows[$nodeobj-&gt;nid] = array( $count++, '&lt;h2&gt;'. l($nodeobj-&gt;title, 'node/'.$nodeobj-&gt;nid) .'&lt;/h2&gt;'. $nodeobj-&gt;teaser ); </code></pre> <p>assuming you get the teaser.</p> <p><strong>EDIT</strong> the previous answer still holds. You can also simplify the code a bit by processing $rows straight in the $noderesults loop.</p> <p>function query_results($searchstring, $datefrom) { $tidresult = db_query("SELECT tid FROM {term_data} WHERE LOWER(name) = '%s'", strtolower($searchstring));</p> <pre><code> $rows = array(); $count = 0; while ($obj = db_fetch_object($tidresult)) { $tid = $obj-&gt;tid; $noderesults = db_query("SELECT n.nid, n.title FROM {node} n " ."INNER JOIN {term_node} tn ON tn.nid = n.nid " ."WHERE tn.tid='%s'", $tid); while ($nodeobj = db_fetch_object($noderesults)) { $rows[] = array( ++$count, l($nodeobj-&gt;title, 'node/'. $nodeobj-&gt;title) ); } } $header = array( array('data' =&gt; 'Nr.'), array('data' =&gt; 'Name'), ); $output = theme('table', $header, $rows); print theme("page", $output); } </code></pre> <p>-OR-</p> <p>move it all in one query (note: I did not get a chance to test this, but I usually get it right the first time):</p> <pre><code>function query_results($searchstring, $datefrom) { $rows = array(); $count = 0; $results = db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {term_node} tn ON tn.nid = n.nid WHERE tn.tid IN (SELECT tid FROM {term_data} WHERE LOWER(name) = '%s')", strtolower($searchstring)); while ($nodeobj = db_fetch_object($results)) { $rows[] = array( ++$count, l($nodeobj-&gt;title, 'node/'. $nodeobj-&gt;title) ); } $header = array( array('data' =&gt; 'Nr.'), array('data' =&gt; 'Name'), ); $output = theme('table', $header, $rows); print theme("page", $output); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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