By Netstat on
Help! I want selecting field field_country_value from table content_type_profile and display him in my profile .Can you edit my module ?Sorry for my bad english.I speak to russian
<?
function select_user($op) {
if ($op == 'view' )
{
$sql = "SELECT field_country_value from content_type_profile";
$result = db_query(db_rewrite_sql($sql));
while ($data = db_fetch_object($result))
{
$country =($data->field_country_value);
$user->content['summary'] = array
(
'#type' => 'user_profile_item',
'#title' => t('Countries'),
'#value' => t($country)
);
}
}
}
?>
Comments
Sorry, I can't figure out
Sorry, I can't figure out what the context is here. What modules are you using -- is this content_profile? Also, just to confirm, this is drupal 6 your asking about?
A couple of comments about your code.
should be:
table names should be always encased in {} and keywords in ALL UPPER CASE.
this really doesn't make sense to me. You've done a query that is likely to return many rows, and then you're using the fetched rows to set values in user->content over and over again. This makes no sense to me. I'm guessing you want to parameterize your query to search on a uid, but given just this code sample it is not clear. Can you provide more context or other information to help us better understand your question?
Thanks!
dougstum I want take out
dougstum I want take out various data from table content_profile
and represent their in my profile http://localhost/drupal/user/1 .
I need any example how can i insert sql query select in module .
Yes i use content profile.
You need to use hook_user(),
You need to use hook_user(), which it appears you are, assuming your module is named 'select'. But you need to add more parameters when you call it. Your function definition should look like this:
function select_user($op, &$edit, &$account, $category = NULL) {Then you can use the value of 'load' for $op to execute your query and load the data into the $account object:
And then you can display the loaded data in when $op is equal to 'view', by adding data to the $account->content array:
Good luck. You should probably spend some time reading over the hook_user() documentation. It's quite convoluted, but very powerful.
Contact me to contract me for D7 -> D10/11 migrations.
Jay Matwichuk Pls check
Jay Matwichuk Pls check syntax
Can you please wrap your code
Can you please wrap your code in <code> tags?
Contact me to contract me for D7 -> D10/11 migrations.
Ok
Ok