Jump to content

separate tag


ohdang888

Recommended Posts

$qry = "SELECT `tags` FROM `your_table`";
$qry = mysl_query($qry);

if (mysql_num_rows($qry) > 0)
{
$vars = array();
while($row = mysql_fetch_assoc($qry))
{
 $vars[] = $row['tags'];
}
$vars = array_unique($vars);
extract($vars,EXTR_PREFIX_ALL, 'var');
$number = count($vars);
for($i=0;$i<$number;$i++)
{
$temp = "var$i";  
echo $$temp;
}
}

 

something like that shoudl do the trick...

Link to comment
https://forums.phpfreaks.com/topic/98557-separate-tag/#findComment-504414
Share on other sites

didn't work. (i found the errors, but it still didn;t work)

thanks though  ;D

 

MadTechie:

I think i will need to do the second one, but one thing...

 

All this info in is under 1 column and there is anywhere between 0 and 10 tags in it. So the list() won't work... (i think ???)

 

So i'm really confused on this, how can i put these on in array or set?

 

Thanks for helping..

Link to comment
https://forums.phpfreaks.com/topic/98557-separate-tag/#findComment-504423
Share on other sites

using ToonMariner  code

<?php
$qry = "SELECT `tags` FROM `your_table`";
$qry = mysl_query($qry);

if (mysql_num_rows($qry) > 0)
{
$vars = array();
$i=1;
while($row = mysql_fetch_assoc($qry))
{
  $vars["var$i"] = $row['tags'];
$i++;
}
//debug
echo "heres the array<br><pre>";
print_r($vars);

//create variables
extract($vars);

echo "$var1 <br>";
echo "$var2 <br>";
echo "$var3 <br>";
echo "$var4 <br>";
//etc
?>

Link to comment
https://forums.phpfreaks.com/topic/98557-separate-tag/#findComment-504439
Share on other sites

really alll you need to do is set the $varable names to what you want really

this is a flash way lol.

 

you mean this

 

re edted sorry.........

<?php

$tags = 'car, motor, automobile, gas, drive, road';

$tags = explode(',', $tags);

//set within the varable names

$car="redarrow";

for($i=0; $i<count($tags); $i++){

    $res[]=trim($tags[$i]);
    }
    
foreach($res as $x){

      echo " All set varables are: $$x<br>";
      
}

     echo "car is now: $car";
?>

Link to comment
https://forums.phpfreaks.com/topic/98557-separate-tag/#findComment-504526
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.