How to call ALL the nodes of a db in the block?
| Project: | Block Theme |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
With the next code, I retrieve the nid in a database that I created with the products that the users have selected, and I use this nid to retrieve its content_fields. The database MyProductsCart has two field: uid and nid. For the moment, in the block, I only have the information related to the first nid (in "MyProductsCart), but there are more nodes stored in it. So my while loop must be false. But I don't know how to fix the code so as to have all the nodes published in the block.
function products_page_block($op='list' , $delta=0, $edit=array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Product Cart');
return $blocks;
case 'view':
global $user;
$uid = $user -> uid;
$query1 = db_query("SELECT * FROM {MyProductsCart} WHERE uid = %d", $uid);
while ($row1 = db_fetch_array($query1)) {
$nid = $row1['nid'];
$row2 = db_fetch_array(db_query("SELECT * FROM {node} WHERE nid = %d", $nid));
$title = $row2['title'];
$row3 = db_fetch_array(db_query("SELECT * FROM {content_field_category} WHERE nid = %d", $nid));
$category = $row3['field_category_value'];
$row4 = db_fetch_array(db_query("SELECT * FROM {content_field_gender} WHERE nid = %d", $nid));
$gender = $row4['field_gender_value'];
$advice = $title.' '.$category;
$blocks['subject'] = t('Your products');
$blocks['content'] = t($advice);
return $blocks; }
Any idea?
