jasonhardwick Posted May 20, 2008 Share Posted May 20, 2008 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 More sharing options...
BlueSkyIS Posted May 20, 2008 Share Posted May 20, 2008 looks like you've got php confused with... something else? This is not PHP: 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/#findComment-546141 Share on other sites More sharing options...
jasonhardwick Posted May 20, 2008 Author Share Posted May 20, 2008 Ok... I found it online somewhere but thats what I get I guess ok so kill that bogus crap how should I pull and seperate the information in colum? Link to comment https://forums.phpfreaks.com/topic/106540-pulling-csv-values/#findComment-546145 Share on other sites More sharing options...
BlueSkyIS Posted May 20, 2008 Share Posted May 20, 2008 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 More sharing options...
DarkWater Posted May 21, 2008 Share Posted May 21, 2008 What you had over there looked like really horrid C++ mixed with really horrid PHP. o-O Link to comment https://forums.phpfreaks.com/topic/106540-pulling-csv-values/#findComment-546172 Share on other sites More sharing options...
jasonhardwick Posted May 21, 2008 Author Share Posted May 21, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.