I'm building a script to pull multiple rows from a db table based on certain criteria and then insert it into one row in another table... but I'm stuck on how to take what I've queried and put it in one variable to insert it into the new table.
PHP Code:
require "db.php";
require "./functions/time.php";
//$sql_time = mysql_real_escape_string($_GET['time']);
$time2 = time();
$time = ($time2-86400);
$q = mysql_query("SELECT * FROM media WHERE time>=$time");
while ($list = mysql_fetch_object($q)) {
$readable = timediff($list->time);
$i = mysql_query("INSERT INTO media (id,mid,title,media,time) VALUES ('NULL','$list->id','','','')") or die('error @ 2 '.mysql_error());
echo "$list->title added $readable<br />";
}
Here is what I'm trying to do...
Select items added in the last 24 hours from one table and then insert them into one row in a new table...
e.g select title 1, title 2, title 3 from table 1 and then insert them into table 2 in one row...
id | title
1 | title 1, title 2, title 3
... but I'm not sure how to get the variables from the loop into an array...
Bookmarks