Help with mimicking a script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Help with mimicking a script

Post by CoolAsCarlito »

I'm trying to mimick this script that I found on a web page and wondered if anyone can help me.

The page that I'm trying to mimmick is located here: http://epw.e-wrestling.org/titlehistories.php?id=1

Code: Select all

 
<?php
// Connects to your Database
$link = mysql_connect("?", "?", "?") or die(mysql_error());
mysql_select_db("?",$link) or die(mysql_error());
 
if (!mysql_select_db("?", $link)) {
echo 'Could not select database';
exit;
}
 
//Define the query
$query = "SELECT * FROM titlehistory";
 
if ($r = mysql_query ($query)){ // Run the query. 
 
 
print '<table border=0 cellspacing="0" cellpadding=3 width=575>';
print '<tr><td background="images/bg_bar4.gif" height=35>&nbsp;<font color="white">Title Histories</font></td></tr>';
print '<tr><td></td></tr>';
print '</table>';
print '<table border=0 cellspacing="0" cellpadding=3 width=575>';
print '<tr><td background="images/bg_bar3.gif" height=35 colspan=2>&nbsp;KOW '.$row['titlename'].'</td></tr>';
print '<tr><td width=200><img src="/images/' . $row['titleimage'] . '" width=208px height=156px border=0 alt="View KOW '.$row['titlename'].' History"></td><td valign=top>';
print '<table cellpadding="2" cellspacing="0" border="0" width=100%>';
print '<tr><td align=center bgcolor=#E0E0E0><b>Date Created</b></td></tr><tr><td align=center>'.$row['datecreated'].'</td></tr>';
print '<tr><td bgcolor=#E0E0E0 align=center><b>Status</b></td></tr>';
print '<tr><td align=center>'.$row['status'].'</font></td></tr>';
print '<tr><td bgcolor=#E0E0E0 align=center><b>Longest Reign</b></td></tr>';
print '<tr><td align=center><a href=bio.php?'.$row['longestreign'].'><b>'.$row['longestreign'].'</b></a> ('.$row['numdays'].')</td></tr>';
print '<tr><td bgcolor=#E0E0E0 align=center><b>Most Successful Defenses</b></td></tr>';
print '<tr><td align=center><a href=bio.php?'.$row['sucessdefenses'].'><b>'.$row['sucessdefenses'].'</b></a> ('.$row['numdef'].')</td></tr>';
print '</table>';
 
 
} else {
die ('<p>Could not retrieve the data because <b>' . mysql_error() . '</b>. The query was $query.</p>');
} //End of query IF 
?> 
 
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Help with mimicking a script

Post by califdon »

What do you mean by "mimicking" a script??
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Re: Help with mimicking a script

Post by CoolAsCarlito »

Okay well first off really the only I want right now is for my titlehistory.php script which shows all of my titles and when you scroll over one it says titlehistory.php?id="whatever" and when you click on it I want it to bring up that titles info which shows all kinds of things.

http://www.kansasoutlawwrestling.com/titlehistory.php

The example page of the info that should show up when you click the title on the title history page.http://www.kansasoutlawwrestling.com/titlehistory3.php
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Help with mimicking a script

Post by califdon »

CoolAsCarlito wrote:Okay well first off really the only I want right now is for my titlehistory.php script which shows all of my titles and when you scroll over one it says titlehistory.php?id="whatever" and when you click on it I want it to bring up that titles info which shows all kinds of things.

http://www.kansasoutlawwrestling.com/titlehistory.php

The example page of the info that should show up when you click the title on the title history page.http://www.kansasoutlawwrestling.com/titlehistory3.php
I've looked at your references. What is it that you want it to do that it isn't already doing?
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Re: Help with mimicking a script

Post by CoolAsCarlito »

Sorry accidently forgot I had already made a post about this.

Here's the forum topic with my code on it.

viewtopic.php?f=1&t=86550&sid=adcc9da1b ... ab1b0034d5
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Help with mimicking a script

Post by califdon »

CoolAsCarlito wrote:Sorry accidently forgot I had already made a post about this.

Here's the forum topic with my code on it.

viewtopic.php?f=1&t=86550
Isn't that the same code that you posted here? If it is, please go back and delete the other post (the one you reference above) so that I won't have to do it for you. Nobody has replied to it yet.

You still haven't answered the question, What do you want it to do that it isn't already doing? When I visited the URL you gave above, it appears to work as I would expect it to. You will have to explain what you want to happen that isn't happening now.
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Re: Help with mimicking a script

Post by CoolAsCarlito »

I deleted the other post. Now the problem is just that it won't post the data from that title.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Help with mimicking a script

Post by califdon »

CoolAsCarlito wrote:I deleted the other post. Now the problem is just that it won't post the data from that title.
OK, finally I understand what you are asking. Assuming that the code above is the complete code, there simply is no code to cause anything to be sent to the browser except for the static HTML. You are missing essentially all of the code necessary to retrieve the data and display it.

You are passing an id in the URL, but you never make any use of it. Since the id is being passed in the URL, the way you get the value is with a line like:

Code: Select all

 $id = mysql_real_escape_string($_GET['id']);
Then, your SQL is retrieving every record in the table `titlehistory`. I would assume that you want to only retrieve the record for the requested id, right? Then your SQL must look like this:

Code: Select all

 $query = "SELECT * FROM titlehistory WHERE id = $id";
Finally, when you run the query, the result is contained in the array $r, but you still have to fetch a row before you can use the variable $row, which your code hasn't defined yet. So you need this kind of code:

Code: Select all

 $row = mysql_fetch_array($r);
Generally, you would need to do that in a while loop, to fetch each row, one at a time. In your case, you're expecting only a single row, so that's not necessary.

That should get you close to what you want.
Post Reply