Computer Help Forum and Programming Advice :: View topic - Selecting Data from MySql Db
View previous topic :: View next topic
Author
Message
mogoo Web Design Newbie Joined: Jan 24, 2006 Posts: 10
Posted: Sat Feb 11, 2006 9:56 pm Post subject: Selecting Data from MySql Db
Hi, I'm trying to make this script SELECT Title,Source FROM ng_main. Then preg_replace $row['Title']['Source'])
Now, it only works with SELECT Title FROM ng_main.
Then preg_replace $row['Title']
Code:
Code: if($_GET[ftype] == 'web') {
$words = file("words.dat");
} else {
$words = array();
$res = mysql_query("SELECT Title FROM ng_main");
// i also need it to "SELECT Source FROM ng_main"
// $res = mysql_query("SELECT Title,Source FROM ng_main"); // didn't work
while ($row = mysql_fetch_array($res))
{
$words[] = preg_replace("/[\r\n]/s"," ",$row['Title']);
//$words[] = preg_replace("/[\r\n]/s"," ",$row['Title']['Source']); // this didn't work either!
}
mysql_free_result($res);
$words2 = array();
$words3 = array();
}
Thank you for your help.
Back to top
ci5co Web Design Newbie Joined: Aug 18, 2004 Posts: 89
Posted: Sat Feb 11, 2006 9:57 pm Post subject:
$row['Title']['Source'] <-- This means that 'Title' would be an array, containing an entry with a 'Source'-key. What you need to do, is to replace both results separately, like this
Code: $res = mysql_query("SELECT Title,Source FROM ng_main");
.....
$words[] = preg_replace("/[\r\n]/s"," ",$row['Title']);
$words[] = preg_replace("/[\r\n]/s"," ",$row['Source']);
_________________White Papers
Internet Marketing
Boku
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum