Jump to content

NEED Help, please!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
12 replies to this topic

#1
SuperSponge

SuperSponge

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
Hello,


If you visit RSGE + [x]Item[x] and you just click 'submit query' or the submit button, you are redirected to save.php, then you are redirected to the item list. I want the item list to be in a table, but it doesn't come up as one..

Save.Php Code:

<html>

<head>

<title>Ohaider</title>

</head>


<body>

<meta http-equiv="Refresh" content="5; url=./forms/description.html">

<?php


$rsn = $_POST[rsn];

$date = $_POST[date];

$mod = $_POST[mod];

$why = $_POST[why];

$data = "$rsn $date $mod $why"; 


//open the file and choose the mode 

$fh = fopen("./forms/description.html", "a"); 

fwrite($fh, $data);


//close the file 

fclose($fh); 


?></table>


Thank for submitting your information. You will be redirected shortly to <b>http://rsge.org/forms/Ohi.html.</b> This is our main buy/sell page. And again, thanks.


</body>

</html>


Description.html (Item List)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>

  <title>Untitled document</title>

</head>

<body>

<p><span style="font-size: medium;"><span style="font-family: 'arial black','avant garde';">Here are the waiting to be sold or people waiting to buy: ( [****] = space between each seller )<br /> </span></span></p>

<p> </p>

</body>

</html>

      

Edited by Orjan, 04 October 2010 - 02:26 PM.
removed non-working link


#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
It's not the best way, to modify the html file with your list like that. I suggest you save the items in a database instead, mysql or sqlite is good suggestions. mysql if you have access to such a server, otherwise sqlite, as it's an database engine shipped with php and only uses a file to store the data, wherever you want.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts

Quote

I want the item list to be in a table, but it doesn't come up as one..
I do not get your question here, can you not create it in table format, or are you having trouble doing so? Is this your code or one you are modifying?

Also @ Orjan's edit, context of a site (and its history revolving) is important.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#4
SuperSponge

SuperSponge

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
Thanks for your reply. Basically, the form is in HTML which I have a bit of experience in but the Save.php is in Php. I want to make so the data is created in a table format with different columns.


Http://rsge.org/item.html - Form
http://rsge.org/forms/save.php - Processing Data
http://rsge.org/forms/ohi.php - Item List (I want this is in table format, automatically)

#5
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Your application flow is a bit off. You are automatically redirecting (through <meta> tag) to description.html, but you say you are redirecting to "ohi.php"?

Now as you are not using a database (only file handling) you will need to be creative in how to append to the table. You may wish to make description.html to this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title>description.html</title>
</head>
<body>
<p><span style="font-size: medium;"><span style="font-family: 'arial black','avant garde';">Here are the waiting to be sold or people waiting to buy: ( [****] = space between each seller )<br /> </span></span></p>
<table>
<tr><th>rsn</th><th>date</th><th>mod</th><th>why</th></tr>
This will mean that each new entry will append to the table. To add to the table with your original code:
$rsn = $_POST['rsn'];
$date = $_POST['date'];
$mod = $_POST['mod'];
$why = $_POST['why'];
$data = "$rsn $date $mod $why"; 

$data = "<tr><td>$rsn</td><td>$date</td><td>$mod</td><td>$why</td></tr>\n";

//open the file and choose the mode 
$fh = fopen("./forms/description.html", "a"); 
fwrite($fh, $data);

//close the file 
fclose($fh); 
But note description.html will not have a </table> tag, as you are appending to it constantly, so you will need to call it through a PHP file instead:

description.php:
print file_get_contents('./forms/description.html');
print "</table></body></html>"; //complete the table for display
This is a bit troubling because you are not using a database, so again you will need to be creative.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#6
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts

Nullw0rm said:

Also @ Orjan's edit, context of a site (and its history revolving) is important.
A link that gives a 404 is of no such use, that's why I removed the link and let the text be left.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#7
SuperSponge

SuperSponge

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
Hello,

I've added in all of the codes, but one problem. RSGE + [x]Item[x] - When you submit an item, it doesn't show up on RSGE + [x]Item Index[x] and it shows the contents of description.php




Description.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>

  <title>description.html</title>

</head>

<body>

<p><span style="font-size: medium;"><span style="font-family: 'arial black','avant garde';">Here are the waiting to be sold or people waiting to buy: ( [****] = space between each seller )<br /> </span></span></p>

<table>

<tr><th>rsn</th><th>date</th><th>mod</th><th>why</th></tr>

Save.php

<html>

<head>

<title>Ohaider</title>

</head>


<body>

<meta http-equiv="Refresh" content="5; url=./forms/description.html">

<?php


$rsn = $_POST['rsn'];

$date = $_POST['date'];

$mod = $_POST['mod'];

$why = $_POST['why'];

$data = "$rsn $date $mod $why"; 


$data = "<tr><td>$rsn</td><td>$date</td><td>$mod</td><td>$why</td></tr>\n";


//open the file and choose the mode 

$fh = fopen("./forms/description.html", "a"); 

fwrite($fh, $data);


//close the file 

fclose($fh);  


?></table>


Thank for submitting your information. You will be redirected shortly to <b>http://rsge.org/forms/Ohi.html.</b> This is our main buy/sell page. And again, thanks.


</body>

</html>

Ohi.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<!--




Design by http://www.bluewebtemplates.com




Released for free under a Creative Commons Attribution 3.0 License




--><!-- Start Quantcast tag -->

  <script type="text/javascript">

_qoptions={

qacct:"p-66oQWKrKqLwEU"

};

  </script>

  <script type="text/javascript" src="//secure.quantserve.com/quant.js"></script>

  <title>RSGE + [x]Item Index[x]</title>

  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

  <link href="style.css" rel="stylesheet" type="text/css">

</head>

<noscript></noscript><body>

<img src="//secure.quantserve.com/pixel/p-66oQWKrKqLwEU.gif"

 style="display: none;" alt="Quantcast" border="0" height="1" width="1"><!-- End Quantcast tag --><!-- CuFon: Enables smooth pretty custom font rendering. 100% SEO friendly. To disable, remove this section -->

<script type="text/javascript" src="js/cufon-yui.js"></script>

<script type="text/javascript" src="js/arial.js"></script>

<script type="text/javascript" src="js/cuf_run.js"></script><!-- CuFon ends -->

<div class="main">

<div class="header">

<div class="header_resize">

<div class="menu_nav">

<ul>

  <li class="active"><a href="rsge.org">Home</a></li>

  <li><a href="forums/">Forums</a></li>

  <li><a href="http://rsge.org/item.php">Sell or Buy an Item<br>

    </a></li>

  <li><a href="blog/">Blog</a></li>

  <li><a href="http://rsge.org/contact.php">Contact Us</a></li>

</ul>

</div>

<div class="logo">

<h1><a href="index.html">RSGE<br>

<small>THE GRandExchange, but better.<br>

</small></a></h1>

</div>

</div>

</div>

<div class="content">

<div class="content_resize">

<div class="mainbar">

<div class="article">

<div class="mainbar"><br>

</div>

<div class="mainbar">

<div class="article">

<div style="text-align: center; font-weight: bold;"><big><big><big><big>					  

Items being sold or bought:<br>

</big></big></big></big></div>

</div>

</div>

<div style="text-align: center;"><iframe

 style="background-color: white;" src="/forms/description.html"

 height="600" width="900">

</iframe><br>

</div>

<h2><br>

</h2>

</div>

</div>

<div class="content">

<div class="content_resize"><br>

<br>

<div class="sidebar">

<div class="gadget">

<h2 class="star"><br>

<span></span></h2>

<h2 class="star"><br>

</h2>

<div class="gadget">

<h2 class="star"><span>Staff</span></h2>

 Owners: <br>

Dinosaur - Founder & Website editor<br>

 inju5tice - Coder<br>

<br>

 Moderators:<br>

  Boldy - Report Expert<br>

<br>

<ul class="ex_menu">

</ul>

</div>

</div>

</div>

</div>

<div class="fbg">

<div class="fbg_resize">

<div class="col c1">

<h2>About</h2>

<img src="images/white.jpg" alt="pix" height="66" width="66">

<p>The RSGE stands for <b>R</b>une<b>S</b>cape <b>G</b>rand<b>E</b>xchange.

The main purpose of the RSGE was to help Runescape players sell or buy

items which they purchase <b>in-game</b> from other players in a new,

hip and cool way! <br>

RSGE is a non-profitable organization and we are not affiliated with

Runescape or Jagex in anyway. The RSGE is owned by myself and Dinosaur.

<br>

</p>

</div>

<div class="col c2">

<h2>Navigation<br>

</h2>

<ul class="sb_menu">

  <li><a href="http://rsge.org/">Home</a><br>

  </li>

  <li><a href="forums/">Forums</a></li>

  <li><a href="http://rsge.org/item.php">Sell or buy an Item<br>

    </a></li>

  <li><a href="http://rsge.org/contact.html">Contact Us<br>

    </a></li>

</ul>

</div>

<div class="col c3">

<h2>Contact</h2>

These are emails and phone numbers of owners. The phone numbers are not

to be used inappropriately. <br>

 <br>

 <span style="font-weight: bold;">Phone</span>: 6145560258<br>

 <span style="font-weight: bold;">Emails</span>: <a

 href="mailto:admin@rsge.org">admin@rsge.org</a><br>

			   

<a href="mailto:inju5tice@rsge.org">inju5tice@rsge.org</a><br>

<span style="text-decoration: underline;"></span></div>

</div>

</div>

<div class="footer">

<div class="footer_resize">

<p class="lf"><br>

</p>

<p class="lf"><br>

© Copyright RSGE. All rights reserved.</p>

<ul class="fmenu">

  <li class="active"><br>

  </li>

  <li><br>

  </li>

</ul>

</div>

</div>

</div>

</div>

</div>

</div>

</body>

</html>



#8
RSGE

RSGE

    Newbie

  • Members
  • Pip
  • 2 posts
@Nullw0rm - Thank you for your help with the php. Unfortunatly this did not wok. I'm still trying out different things.
@Orjan - Thanks for deleting the link, I guess, but still, I changed all pages to .php instead of .html.

#9
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Try to keep one account, or warn us you are the OP atleast.

Where are you stuck at? It still may be hard to write, as you're using a somewhat complex scenario to write data to a file that is reused. Personally I would log data to a file, and not an HTML file, say:

$rsn = $_POST['rsn'];
$date = $_POST['date'];
$mod = $_POST['mod'];
$why = $_POST['why'];

//tab delimited file
$data = "$rsn\t$date\t$mod\t$why\n"; 

$fh = fopen("./forms/data.txt", "a"); 
fwrite($fh, $data);

//close the file 
fclose($fh);

Then just to keep it simple, here is an example PHP form that would display the data in a proper table this time (should work):
$data = file_get_contents('./forms/data.txt');
$lines = explode("\n", $data); //separate into lines

print "<table><tr><th>rsn</th><th>date</th><th>mod</th><th>why</th></tr>\n";
foreach($lines as $line) {
    $data = explode("\t", $line); //separate into data
    //formulate table
    print "<tr><td>{$data[0]}</td><td>{$data[1]}</td><td>{$data[2]}</td><td>{$data[3]}</td></tr>";
}
print "</table>"; //done!

That is much easier than what you were doing, and makes data into a nice friendly data file for you.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#10
RSGE

RSGE

    Newbie

  • Members
  • Pip
  • 2 posts
@NullW0rm

Sponge and I are co-owners of RSGE. This is not sponge. And thanks, this code should work.

In addition to that code, this:

$data = file_get_contents('./forms/data.txt');

$lines = explode("\n", $data); //separate into lines


print "<table><tr><th>rsn</th><th>date</th><th>mod</th><th>why</th></tr>\n";

foreach($lines as $line) {

    $data = explode("\t", $line); //separate into data

    //formulate table

    print "<tr><td>{$data[0]}</td><td>{$data[1]}</td><td>{$data[2]}</td><td>{$data[3]}</td></tr>";

}

print "</table>"; //done!

Goes where? save.php or description.php? And btw the Ohi.php shows an iframe display of "description.php" Please respond I am new and still learning PHP.

#11
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Description.php I would assume, because it will display the table of the data entered by my last save.php
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#12
SuperSponge

SuperSponge

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
RSGE + [x]Item Index[x]