Jump to content

Help in php /mysql data extracting


djbuddhi

Recommended Posts

<?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);

?>

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();

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.