The14thGOD Posted March 25, 2008 Share Posted March 25, 2008 I can't seem to figure out why this won't work and no one else I've shown it too can either (a whole 2 other ppl). Any help would be nice, thanks in advance =D. Edit----- I should explain what's not working! HA! Basically it just goes through the first data1 entry, it doesn't hit the others. So it basically loops through one table and stops, it never goes to data2 etc etc. ---edit done Some things have been removed like specific names. Basically I'm taking data from multiple tables and putting it into one giant table (the way it should have been set up but for a specific reason I set it up differently and then never did what I was going to do.) <?php include("old_connect.php"); $array = array('data1','data2','data3','data4','data5','data6','data7','data8'); for($i=0;$i<8;$i++) { $select_table = 'table_'.$array[$i]; $query = "SELECT * FROM $select_table"; $results = mysql_query($query); $description = addslashes($row[description]); while($row = mysql_fetch_array($results)) { include("connect.php"); $add_date = "INSERT INTO art (abc,def,ghi,jkl,lmn,opq,rst,uwv,xyz,status) "; $add_data.= "VALUES ('$row[abc]','$array[$i]','$row[def]','$row[ghi]','$row[jkl]','$row[lmn]','$row[opq]','$row[rst]','$description','$row[status]')"; mysql_query($add_data); if(mysql_error() != "") { echo(mysql_error()); exit(0); } } } header("Location: http://www.google.com"); ?> Thanks Again, Justin Quote Link to comment Share on other sites More sharing options...
NikkiLoveGod Posted March 25, 2008 Share Posted March 25, 2008 Well, it doesnt hit me right now, why exactly your loop doesnt work, but heres a few ideas. $description = addslashes($row[description]); Shouldnt that be AFTER you define what $row holds? and try taking the if sentence away from the end, see if it works then? Though it should give up an error... make sure that you have all the tablenames and such correct. Quote Link to comment Share on other sites More sharing options...
The14thGOD Posted March 25, 2008 Author Share Posted March 25, 2008 Ah, yea sorry I copied the wrong version, it's actaully after that (that was one thing that we tried just for ****s and giggles). It's actually after the while. I'll try taking out the if too and get back to you, going to bed right now though. If anyone else has any ideas please let me know, ty again =D Justin Quote Link to comment Share on other sites More sharing options...
teng84 Posted March 25, 2008 Share Posted March 25, 2008 ignore Quote Link to comment Share on other sites More sharing options...
The14thGOD Posted March 25, 2008 Author Share Posted March 25, 2008 Alright, I tried that and it didn't do anything different. I can do it w/o using the loop, just switch it manually, not really that big of a deal...but still would like to know why it's not looping. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.