vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Seperate a value (https://vborg.vbsupport.ru/showthread.php?t=185533)

mokujin 07-16-2008 08:38 PM

Seperate a value
 
Hi, can you help me with seperating?

I have ex. this script:

PHP Code:

    // Get details
    
$sql $vbulletin->db->query_read(
    SELECT field1 
    FROM " 
TABLE_PREFIX "mytable AS mytable
    "
); 

if field1 has 2 words is seperating with a comma
ex. "word 1, word2",
How can I show for each word in template with
HTML Code:

<a href="myfile.php?do=word 1">word 1</a>, <a href="myfile.php?do=word2">word2</a>
Sorry for my bad English, I cant say better :mad:

Opserty 07-16-2008 08:46 PM

PHP Code:

$query $vbulletin->db->query_read(
    SELECT field1 
    FROM " 
TABLE_PREFIX "mytable
    "
);  
while(
$row $vbulletin->db->fetch_array($query))
{
    
$words explode(','$row['field1']);
    foreach(
$words as $word)
    {
        echo 
'<a href="myfile.php?do='htmlspecialchars_uni($word) .'">'htmlspecialchars_uni($word) .'</a>';
    }



mokujin 07-16-2008 08:54 PM

Oh thank you for your replying, but I need it in template. If I use your code it shows in top of the page :(

RLShare 07-17-2008 03:08 AM

You have to put the php code in a plugin that hooks at the proper location.

Opserty 07-17-2008 08:34 AM

Change
PHP Code:

echo 

To:
PHP Code:

$somevarx .= 

Then use [minicode]$somevarx[/minicode] in your template.

mokujin 09-27-2008 08:16 PM

Hi again,
I have now another problem with seperating (using foreach function)
If I have SELECTED 3 rows from Database.
From second and third row they will repeat what previous row has.

Something like this:

Row 1: mytext, text
Row 2: thisis, thetext
Row 3: someword, my word

Then in template shows:
1: mytext, text
2: mytext, text, thisis, thetext
3: mytext, text, thisis, thetext, someword, my word

I think you will understand what I mean, thanks for helping me :(


All times are GMT. The time now is 10:55 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02472 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_html_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete