djbuddhi Posted February 15, 2008 Share Posted February 15, 2008 how to xtract the data in a sql before the || tags ex: jason || tommy || bull above text was appearing in a sql query and i want to extract jason,tommy and bull from the quey how to do it , i use php with mysql Link to comment https://forums.phpfreaks.com/topic/91189-help-in-php-mysql-data-extracting/ Share on other sites More sharing options...
Northern Flame Posted February 15, 2008 Share Posted February 15, 2008 <?php $host = "localhost"; // your mysql host $user = "username"; // your mysql username $pass = "password"; // your mysql password $db = "database"; // your mysql database $conn = mysql_connect($host, $user, $pass); mysql_select_db($db, $conn); $table = "table_name"; // your table name $query = mysql_query("SELECT * FROM $table")or die(mysql_error()); while($row = mysql_fetch_array($query)){ echo $row['name'] . " || "; // replace name with column name } mysql_close($conn); ?> Link to comment https://forums.phpfreaks.com/topic/91189-help-in-php-mysql-data-extracting/#findComment-467347 Share on other sites More sharing options...
djbuddhi Posted February 15, 2008 Author Share Posted February 15, 2008 hey this is not i want i want to get the data without the || , the above test is in the test field out put should be jason tommy bull Link to comment https://forums.phpfreaks.com/topic/91189-help-in-php-mysql-data-extracting/#findComment-467543 Share on other sites More sharing options...
rameshfaj Posted February 15, 2008 Share Posted February 15, 2008 Why dont use explode function or get some substrings of the resulted row? Link to comment https://forums.phpfreaks.com/topic/91189-help-in-php-mysql-data-extracting/#findComment-467545 Share on other sites More sharing options...
redarrow Posted February 15, 2008 Share Posted February 15, 2008 why you got || in the database firstly..... <?php $host = "localhost"; // your mysql host $user = "username"; // your mysql username $pass = "password"; // your mysql password $db = "database"; // your mysql database $conn = mysql_connect($host, $user, $pass); mysql_select_db($db, $conn); $table = "table_name"; // your table name $query = mysql_query("SELECT * FROM $table")or die(mysql_error()); while($row = mysql_fetch_array($query)){ $result=str_repalce("||"," ",$row['name']); echo $result; } mysql_close($conn); ?> look up str_replace(); Link to comment https://forums.phpfreaks.com/topic/91189-help-in-php-mysql-data-extracting/#findComment-467553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.