Jump to content

Pulling CSV Values


jasonhardwick

Recommended Posts

I"ve got a colum in my database with multiple entries that are seperated by commas (network) now i'm trying to display them and link with this

<a href="user_profile.php?username=<? echo $rows['network']; ?>"><? echo $rows['network']; ?></a>

 

but obviously with just this i  get a long link with all of the infor in my "network" colum

 

so i tried to implement something like below but i get an error " Parse error: parse error, unexpected T_STRING in /home/content/j/a/s/jasonhardwick/html/index.php on line 254"

 

note-- line 254 is " string network = $network_id; "

 

 <?php
include "config.php";
$tbl_name="user";
$sql="SELECT * from forum_question WHERE username = '{$_SESSION['username']}' ORDER BY datetime ASC LIMIT 0,1000";
$result=mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {

$network_id = $rows['network'];
//echo $network_id;
string network = $network_id;
string [] split = network.Split(',');

foreach (string item in split)
    Console.WriteLine(item);

?>

Link to comment
https://forums.phpfreaks.com/topic/106540-pulling-csv-values/
Share on other sites

something more like this:

 

<?php
include "config.php";
$tbl_name="user";
$sql="SELECT * from forum_question WHERE username = '{$_SESSION['username']}' ORDER BY datetime ASC LIMIT 0,1000";
$result=mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {

        $network_id = $rows['network'];
        $network_id_parts = explode(',',$network_id);
        
        foreach ($network_id_parts AS $a_nid_part) {
                echo "$a_nid_part <BR>";
        }
}

?>

Link to comment
https://forums.phpfreaks.com/topic/106540-pulling-csv-values/#findComment-546147
Share on other sites

LOL, yeah im sure it is... but thanks for the help Blue

 

So I've modified it (into horrid php) how can I put the "$a_nid_part" into a grid?

right now they ar ust listed

 

<?php
include "config.php";
$tbl_name3="user";
$sql3="SELECT * from $tbl_name3 WHERE uname = '{$_SESSION['username']}' ORDER BY id ASC LIMIT 0,1000";
$result3=mysql_query($sql3) or die(mysql_error());
while ($row3 = mysql_fetch_assoc($result3)) {

        $network_id = $row3['network'];
        $network_id_parts = explode(',',$network_id);
        
       foreach ($network_id_parts AS $a_nid_part) {
?>            
            <p><b><a href="user_profile.php?username=<? echo $a_nid_part; ?>"><? echo $a_nid_part; ?></a></b>
            <p>
  <?php
    }
}

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/106540-pulling-csv-values/#findComment-546264
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.