Youko Posted June 12, 2007 Share Posted June 12, 2007 Okay. I have a table with few columms. Can I make it so that a php file checks every time it's ran that if a new row has appeared in a table and after that insert theese few lines to a end of a file: $rank_no4 = "blah blah"; $rank_no4_pic = "<img src='".THEME_ABS."blah/blah.jpg' />"; I'd want that the $rank_no<number> goes acording to the newest ID in the table. Is this possible? Quote Link to comment https://forums.phpfreaks.com/topic/55202-solved-i-wonder-if-this-will-work/ Share on other sites More sharing options...
btherl Posted June 12, 2007 Share Posted June 12, 2007 The easiest way (that I can think of) to achieve this is to have an extra column in your table that records whether or not the row has been added to the file. Then you can just do a query with "WHERE added = false ORDER BY id". I'm not sure how much detail you want, so ask again if you need more. Quote Link to comment https://forums.phpfreaks.com/topic/55202-solved-i-wonder-if-this-will-work/#findComment-272890 Share on other sites More sharing options...
Youko Posted June 12, 2007 Author Share Posted June 12, 2007 Sorry, I'm pretty new at this. If you could go into a greater detail on how doing that, please. Quote Link to comment https://forums.phpfreaks.com/topic/55202-solved-i-wonder-if-this-will-work/#findComment-272898 Share on other sites More sharing options...
smc Posted June 12, 2007 Share Posted June 12, 2007 As I understand your problem I'd agree with btherl. Basically this is what you want to do. Create a new column in your MySQL database, lets say we call it "added" Now, what we want to do is have the PHP script check to see if it finds any that have a "true" value in this column (implying the PHP script already dealt with it) or "false" implying the script hasen't dealt with it yet. Lets take a look at the code below: <?php connect_to_database_function(); $my_query = mysql_query( "SELECT * FROM myTable WHERE added != 'true'" ); //The above query will find all the rows in your database that DO NOT have a "true" value in the "added" column //Now I assume you have a way of identifying which row is which. Sub that method in for the value of "ID" which I will use as an example. //I also assume by this point in the script you have already modified the file to your wishes $my_query = mysql_query( "UPDATE myTable SET added = 'true' WHERE row_id = '$dealt_with_id'" ); ?> I hope this clears it up at least a little Quote Link to comment https://forums.phpfreaks.com/topic/55202-solved-i-wonder-if-this-will-work/#findComment-272906 Share on other sites More sharing options...
Youko Posted June 12, 2007 Author Share Posted June 12, 2007 Thanks, that helped me a lot. Quote Link to comment https://forums.phpfreaks.com/topic/55202-solved-i-wonder-if-this-will-work/#findComment-272953 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.