Page 1 of 1

Opinion greatly appreciated!

Posted: Sun Nov 04, 2007 7:38 pm
by mrsleep99
I'm interested in how I might go about this idea.
I'm interested in writing a PHP script where I'd have an admin page (admin.php or something) where I can enter a subject (let's say "Toy Trucks") and code that would automatically relate to the subject (let's say code that generates contextual adverts from Amazon.com), when I click submit I'd want it to be added to a table in a new row on a main page the users see (maybe index.php or something).
My questions are:

1.) Can I use tables to do this?

2.) Will contextual advertisements work like that or does everything (meaning the "subject" and advertisement) need to be in one cell (or div)?

3.) Any general advice about how to do this? I'm confident I can get the SQL end of it running and the PHP code itself but the two questions above are my main concern, any and all advice is welcome however, thank you!!!

Posted: Mon Nov 05, 2007 12:08 am
by califdon
1.) Certainly. You can store virtually anything in a table.

2.) There is no restriction on what or where you put content in a page.

3.) I'm not getting a clear picture of what you want to do. Do you want to have an admin page where you manually set the nature of the material that appears on a public page? There are several ways you could do that, but it seems like it's not a very useful tool for real-world advertising. I mean, usually ads are selected based on some other criteria, and how would you prove to your advertisers that their ads were displayed, if you could arbitrarily change it?

If you really want to do this, though, one straightforward way would be to have a database with the content (or the pointer to the content) for each different alternative ad, and another table with just one row and one column, that would store the id of the currently selected option. Your admin page would update that one row. Your public page would be generated by a server script that checks for what content to place wherever you want it.

Posted: Mon Nov 05, 2007 12:50 pm
by mrsleep99
Hey,
Thanks for the fast response.
To elaboroate on what it is I'm trying to do, here's what I want the user end to look like.

http://img476.imageshack.us/img476/7602/55384807zt5.jpg

I want the advertisement in the 3rd column to know what is in column 1 and make a relevant ad for it, if using tables I think all this data would need to be in the same cell so the ad has some relation to it. The admin area would just be a place to ad data to another row for column 1, 2 and 3. When I'd click submit in the admin area it'd add the row with the appropriate data. Does this make more sense..?

Posted: Thu Nov 08, 2007 11:01 pm
by mrsleep99
bumppp :oops:

Posted: Sat Nov 10, 2007 5:33 pm
by califdon
mrsleep99 wrote:Hey,
Thanks for the fast response.
To elaboroate on what it is I'm trying to do, here's what I want the user end to look like.

http://img476.imageshack.us/img476/7602/55384807zt5.jpg

I want the advertisement in the 3rd column to know what is in column 1 and make a relevant ad for it, if using tables I think all this data would need to be in the same cell so the ad has some relation to it. The admin area would just be a place to ad data to another row for column 1, 2 and 3. When I'd click submit in the admin area it'd add the row with the appropriate data. Does this make more sense..?
I'm afraid I still don't understand what you want to do. Is the item in column 1 (and 2) of the same row going to change from time to time? If not, I don't see what you want to do; just put whatever you want in column 3 at the time you put something in column 1. If you're going to be frequently changing the contents of each row (not just adding a new row), then you probably need a table of matching "column 1" content and "column 3" content.

Are you planning to create this page dynamically with PHP? Then, you could do something like:

Code: Select all

. . .
$result=mysql_query("SELECT col1, col2, col3 FROM tablename WHERE id=$whatever");
$row=mysql_fetch_array($result);
$col1=$row['col1'];
$col1=$row['col2'];
$col1=$row['col3'];
echo "<tr><td>$col1</td><td>$col2</td><td>$col3</td></tr>";
The way you organize the data on the page, using an HTML table, has nothing whatsoever to do with obtaining the appropriate data. What "cell" it appears in on the page is irrelevant. You determine that when you write the HTML.

I don't know what else to tell you without knowing more about what you're trying to do.

Posted: Sat Nov 10, 2007 6:32 pm
by mrsleep99
Let's say I have 3 columns (and 3 rows in this particular case) and in column 1 is a list of products (apples, crackers, zuchninis) and in column 2 is the description of the food product (apples are fruit, crackers are like bread, zuchinis are a vegetable) and in column 3 I will have a few lines of code, let's say from Amazon.com that generates a relevant ad to whatever content it finds. This ad code would look like:

Code: Select all

<script type="text/javascript"><!--
  amazon_ad_tag = "test-20";  amazon_ad_width = "728";  amazon_ad_height = "90";//--></script>
<script type="text/javascript" src="http://www.assoc-amazon.com/s/ads.js"></script>
This code would remain the same for every single row in column 3.

Here's a visual example: Image

With that explained, the whole scheme is the following. I'd like to have it so I can go to an admin page, enter in the data for a new product (column 1), a new description for that product (column 2) and have the add code automatically insert itself in column 3. When I click submit, it'll enter the information into the SQL database and when the user goes to the main page it will appear, alphabetically ordered with the rest of the products on the page.


Thank you so much for listening, let me know if this makes more sense please.

Posted: Sat Nov 10, 2007 7:32 pm
by Christopher
Since your HTML is the same in every record it might make more sense to do this:

Code: Select all

name     description         ad_tag     ad_width  ad_height

apples   apples are fruit  test-20     728           90
...
The build the HTML from the values.

Code: Select all

<script type="text/javascript"><!--
  amazon_ad_tag = "<?php echo $row['ad_tag']; ?>";  amazon_ad_width = "<?php echo $row['ad_width']; ?>";  amazon_ad_height = "<?php echo $row['ad_height']; ?>";//--></script>
<script type="text/javascript" src="http://www.assoc-amazon.com/s/ads.js"></script>
It still is not clear what you are trying to do.

Posted: Sat Nov 10, 2007 7:56 pm
by mrsleep99
What didn't you understand so maybe I can elaborate?

My main question following my explanation is can I use tables to do this, assuming I'm continuously needing to add rows to the 3 respective columns, and if I can use tables, will I easily be able to use the contextual ad code to relate to the product name in the first column. Please let me know specifically what you don't understand, thank you!

Posted: Sat Nov 10, 2007 8:25 pm
by Christopher
I think you want to be able to enter keywords in a form and have the script search a database table for a match and generate a link from the data in the row found. But then you say things like, "added to a table in a new row on a main page the users see" and I get confused because tables are in databases, not one pages (which may include code that accesses tables). I am not clear about how or what you want to add based on searches.

Posted: Sat Nov 10, 2007 10:55 pm
by Bogey
You don't always have to use a sql database... you can have it stored in a 'dat' file and the index file calling on it... all PHP... I might be able to come up with something for you later on... right now it's too late (night) :D

Posted: Sat Nov 10, 2007 11:10 pm
by mrsleep99
arborint: I'm talking about both kinds of tables. I am talking about HTML tables with <tr><td> etc. and I've also been talking about SQL db's. When I've mentioned tables so far I'm talking about just the HTML kind. I'm looking to take the information from the SQL db which IS in a table and have it generated into a HTML table. I'm not talking about using keywords but rather having the page simply query the db and present the information in a HTML table.