Jump to content

Archived

This topic is now archived and is closed to further replies.

Kylo

Linked Pages?!

Recommended Posts

I have been doing a lot of google searching and such but still havent be able to come up with anything to help me with what I need, and I finally found this site and decided I will post to see if anybody can help. I am currently trying to code my clan site (best viewed in IE, Firefox hates me), and I am trying to find a way to make information update itself on multiple pages by only changing it on one. I know this can be done, cause I have seen it mentioned, but never seen any code. I dont know php or how to make or code a database. So all the more help, the better I can understand to help someone else if needed.

Alright, my test site is www.nwn2world.com/Veneratio2

The information I want to update on all pages is the "Latest Demos", "Latest Matches" and "Veneratio Misc." Boxes. (Again, please view in IE for best results atm) Thank you.

Share this post


Link to post
Share on other sites
I don't know what you mean.

Share this post


Link to post
Share on other sites
What I wana do is make it so if I changed the "Latest Demos" section on the index.html it will automatically change the other .html pages like roster.html, sponsors.html and so forth. This way I dont have to manually edit each page by itself.

Share this post


Link to post
Share on other sites
Well, yes, that's going to require centralized content... usually in a DB, though there are all sorts of ways to cheat.

Share this post


Link to post
Share on other sites
okay, which is the easiest way, cause I aint the hotest with DBs and such. Which code would I insert into those cells.

Share this post


Link to post
Share on other sites
It's not so simple... if you want dynamic content that's MySQL / PHP driven, you're definitely on the correct website ;-)  But it's not just a cut-and-paste job.

Share this post


Link to post
Share on other sites
well, I have created a database and a table within the db called demos.... trying to get this code to work in my .html page now... I tried this...


<?php
$db = mysql_connect("localhost", "root", "");
mysql_select_db("nwn2wor_veneratio",$db);
$result = mysql_query("SELECT * FROM `demos` WHERE 1`demo1``demo2``demo3``demo4``demo5`",$db);
echo "<TABLE>";
while($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>";
echo $myrow["demo1"];
echo "<TR><TD>";
echo $myrow["demo2"];
echo "<TR><TD>";
echo $myrow["demo3"];
echo "<TR><TD>";
echo $myrow["demo4"];
echo "<TR><TD>";
echo $myrow["demo5"];
}
echo "</TABLE>";
?>

Share this post


Link to post
Share on other sites
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/nwn2wor/public_html/Veneratio2/index.php on line 113

this is what I got back, but if I am going to have to put in my user and password... cant someone steal that?

Share this post


Link to post
Share on other sites
alright... I am trying this but getting a parse error...
[code]
<?php
$db = mysql_connect("localhost", "******", "********");
mysql_select_db("nwn2wor_veneratio",$db);
$result = mysql_query("SELECT * FROM `demos`",$db);
or die("Query failed: $sql<br />".mysql_error());
if(!mysql_num_rows($result))
  {
  echo "No results returned by query $sql";
  }
else
  {
"<TABLE>";
while($myrow = mysql_fetch_array($result))
{
"<TR><TD>";
$myrow["demo1"];
"</TR></TD>";
"<TR><TD>";
$myrow["demo2"];
"</TR></TD>";
"<TR><TD>";
$myrow["demo3"];
"</TR></TD>";
"<TR><TD>";
$myrow["demo4"];
"</TR></TD>";
"<TR><TD>";
$myrow["demo5"];
"</TR></TD>";
}
"</TABLE>";
?>
[/code]

also... cant someone just view source and see the login/password?

mod edit  : security data removed and code tags added

Share this post


Link to post
Share on other sites
No not when php parses it.  You should remove the password from your post though.  What I meant was that when you put it on your site and PHP parses it won't be shown.

Share this post


Link to post
Share on other sites
If someone tries to view a php page all they see is the generated HTML output.

However, you could/should put the security data in an include file located outside the web root directory tree for added security.

Share this post


Link to post
Share on other sites
Ok this should work for you.

[code]
<?php

$db = mysql_connect("localhost", "******", "******");
mysql_select_db("nwn2wor_veneratio",$db);
$result = mysql_query("SELECT * FROM `demos`",$db) or die("Query failed: $sql".mysql_error());

if(!mysql_num_rows($result))
echo "No results returned by query $sql";
else
{
echo '
<TABLE>';

while($myrow = mysql_fetch_assoc($result))
{
echo '
<TR>
<TD>', $myrow["demo1"], '</TD>
<TD>', $myrow["demo2"], '</TD>
<TD>', $myrow["demo3"], '</TD>
<TD>', $myrow["demo4"], '</TD>
<TD>', $myrow["demo5"], '</TD>
</TR>';
}

echo '
</TABLE>';
}
mysql_free_result($result);
?>
[/code]

Share this post


Link to post
Share on other sites
[quote author=Barand link=topic=110531.msg447491#msg447491 date=1160078443]
So much for reporting his post re password inclusion :/
[/quote]
I realized that I forgot to edit that after I posted.  I edited the post right away though.

Share this post


Link to post
Share on other sites
ahhh, its all good, I delete that db user and created a new one with new password.

I got the code to work by tweaking the table to this..

{
echo '
<TR>
<TD>', $myrow["demo1"], '</TD></TR>
<TR>
<TD>', $myrow["demo2"], '</TD></TR>
<TR>
<TD>', $myrow["demo3"], '</TD></TR>
<TR>
<TD>', $myrow["demo4"], '</TD></TR>
<TR>
<TD>', $myrow["demo5"], '</TD></TR>
</TR>';
}


and now the it looks perfect on my site, thank you.

Share this post


Link to post
Share on other sites
just one last question.... if I wanted to link one of those demo1 or demo2 to a file to download, what would I do to edit the code?

Share this post


Link to post
Share on other sites
Store

[code]
<?php
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("nwn2wor_veneratio",$db);
?>

[/code]

in a file called, say, "connect.inc.php" and store that on the server outside the web root directory tree.

In you scripts that need to acces the db

[code]
<?php
include 'connect.inc.php';
?>
[/code]

Share this post


Link to post
Share on other sites

×

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.