Click to See Complete Forum and Search --> : Building a list
Vasilli
06-28-2003, 09:36 PM
Hi,
I am trying to build a dynamic page for a client that indexes a bunch of companies in a specific heading (like say a bunch of coffee shops).
What the client wants is then after you have look at all of the companies, you can pick a number of them with a check box and click on a button at the bottom of the page which will inturn take the information on that page (all advertisements will be placed within their own table) and place it on another page, along with all the other advertisements you selected with their appropriate checkboxes
I suppose it is like you see on some pages where you can compare more than one product on it's own page.
I hope that i have made sense and someone can help me
Thanks for your time
I'm sorry, but I don't understand what you are trying to do... Could you please try to explain better?
Vasilli
06-28-2003, 10:21 PM
ok what I am building is in essence a list of companies with advertising links to their web page (if they have one) and a little about them along with address and telephone number.
I will include a text file on one of the advertisements so you can see the format of the advertisement (HTML format).
Then what I "HOPE" to be able to do is to have a list of say 10-15 advertisements on a page and allow the visitor to select one 2, 3 or four of them and post them (I would assume it would be a function in PHP??) to another page, in the same format as was on the original so that they can print this information for later viewing.
So lets say you have 5 companies on a page
1) Franks pizza
2) Cathy’s pizza
3) Pyro's pizza
4) Tina’s pizza
5) John's pizza
All with a little information in a table and I want to copy the information for Pyro's pizza and John's pizza to another page so I can print it or just look at it
That is in reality what I am trying to do, to me it sounds like it wouldn't be a huge job, then again I have no idea where to start with PHP so I thought I would see if it is as simple as I envisioned it to be!
Be blunt with me doc…. :)
Ok, are you using a database or a flatfile to pull the values? If you are just using HTML files, it's going to be tougher... (ie. you will have to put comments around each entry, so a PHP script can split up the file and take what it needs.) So, basically, tell me how the compainies are originally written to the HTML page.
Vasilli
06-28-2003, 10:37 PM
hmmmm, I have not fully worked out databases yet, so I am using straight html (the riles are not named this however they have a PHP extension, not that that would matter i would assume)
i do have access to a database on the server, for the client also wants a forum (am using phpBB2, because I liked the price! ) and so the do have web space where this is possible.
The demo.txt file i posted is the basis template for each advertiser, so when you say you would have to put comments around each entry what would that mean? Does it mean each table, or each piece of data in each cell and then post to a new table on a blank page? (Hope that made sense)
So in reply to your question NO, I have not built it in a database, only straight html.
Alright, using the html (or php) file is fine. Here's a quick and dirty demonstration:
yourmainpage.php
<html>
<head>
<title>Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="760" border="0" cellspacing="0" cellpadding="0">
<!--Franks Pizza-->
<tr>
<td colspan="5" align="center" valign="middle"><strong><em>Franks Pizza</em></strong></td>
</tr>
<tr>
<td width="170" align="center" valign="middle"><img src="http://www.brizride.com.au/images/3wrx.jpg" width="120" height="120" border="0"></td>
<td width="5"> </td>
<td width="400" valign="top"> This is where the little bit of text would sit.
This is where the little bit of text would sit.This is where the little
bit of text would sit.This is where the little bit of text would sit.This
is where the little bit of text would sit.This is where the little bit of
text would sit.This is where the little bit of text would sit.</td>
<td width="7"> </td>
<td width="170" valign="top"><p>ph: 38512202</p>
<p>address here</p></td>
</tr>
<!--Franks Pizza-->
</table>
</body>
</html>
Now this page will extract the data for Frank's Pizza:
extract.php
<?PHP
$text = "";
$contents = file("yourmainpage.php");
foreach ($contents as $line) {
$text .= $line;
}
$text = split("<!--Franks Pizza-->",$text);
echo $text[1];
?>
Vasilli
06-28-2003, 11:12 PM
Pyro i can see how that would work, however i am still a little bit confused.
i don't understand how to send the info to a page.
Would i need to place <form> tags around all of the adverts, so i could, use a chech box to select the adverts i want to post/view on the page?
The reason i ask is i know how to send information form a form (ie an email form) to a page, and i would think this would be simmilar?
i am still a little lost. thanks for your help so far, you have been a great help!!
Jono
Vasilli
06-28-2003, 11:26 PM
i will try to make more sense of my previous post (sorry)
Because i am trying to allow the user to select, and then view the selected information, i would assume that you would need to allow them to select it with a checkbox or radio button or something simmilar.
how would you do that?
What you would want to do is set up a form, and give the checkboxes values that are the same as the comments that set each entry appart. Then, when a user submits the form, you can get the values, and use these to loop through the page and pull out the values needed.
I put together a little demo. Check if this is close to what you are looking for: http://www.infinitypages.com/temp/extract_1.php
Vasilli
06-29-2003, 05:10 PM
Pyro this is EXACTLY what I am looking for, thank you so much. if I could ask 1 last thing of you? could you post the PHP script you used on that temp page so as I can use it!! I would be so grateful.
Yet again you have saved me, 2 times in as many days, doing well. Again I am in your debt.
thank you
Yep, I just wanted to make sure it was what you were looking for before I posted the code. Anyway, it is attached.
Vasilli
06-29-2003, 05:29 PM
I would like to thank you so very much for your help!! you have saved me yet again!!
You shall now be referred to as PHP God Pyro. :p
Have a great rest of the day/night
Jono
lol...:D
I'm glad I was able to help!
Cheers...
Vasilli
06-29-2003, 10:02 PM
Sorry to do this to you, you have helped me enough already!!
What i am wondering is if you can add more than 1 page, that is allowed to use the extractor?
like this
<?PHP
$text = "";
$contents = @file ($_SERVER['DOCUMENT_ROOT'].'/extract_1.php');# as in add another one in here ie extract_2.php
foreach ($contents as $line) {
$text .= $line;
}
echo "<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
foreach ($_POST as $key => $value) {
if ($key != "submit") {
$newtext = split("<!--$value-->",$text);
echo $newtext[1];
}
}
echo "</table>";
?>
if this is possable it would be great, however if not that is on too (the reason i ask is i have to use this code in around 60 pages!! and that is alot if you have to have a different sheet for each!!)
thank you again
Jono
Heck, it's much easier to ask if there is a way to dynamically do it for all pages than to go through and manually add it in on each of them. If you have questions, by all means, keep asking. :) All I ask is that you try to learn from what I post... ;)
This should work... What it does is grabs the referring URL and uses that:
<?PHP
$text = "";
$contents = @file ($_SERVER["HTTP_REFERER"]);
foreach ($contents as $line) {
$text .= $line;
}
echo "<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
foreach ($_POST as $key => $value) {
if ($key != "submit") {
$newtext = split("<!--$value-->",$text);
echo $newtext[1];
}
}
echo "</table>";
?>
Vasilli
06-29-2003, 10:20 PM
Heck, it's much easier to ask if there is a way to dynamically do it for all pages than to go through and manually add it in on each of them.
This is quite true!! adding them all manually would take a while!!:D
I should have known you would know of a way to add them dynamically, being for the fact you not just good at PHP, no no you are a PHP God!! hehe
Thank you, what you have written here is Great, it will come in very handy indeed!! thank you very much.
and yes i am learning HEAPS from you, who knows maybe i will someday be reffered to as a PHP god too. hehe
Thank you
Jono
lol... :D Glad it worked for you. Let me know if there is anything else I can do for you.
Cheers! :)