Jump to content

[SOLVED] I wonder if this will work.


Youko

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.