SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 6th, 2002, 01:04 AM
MAbans MAbans is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: San Diego CA USA
Posts: 217 MAbans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to MAbans Send a message via Yahoo to MAbans
Need some simple help

My data base is like setup like so:

database - videogames
table - games
gameID | title | genre | platform | summary | rating | review

I have this code that displays the GameID | title| Genre | platform in table using this code.

<?php


/* This should show off all the tables with games included */

echo "<h2>Video games you have</h2>n"
. "<table cellspacing=15>n"
. "<tr><td colspan=5><hr></td></tr>n";

while ($row = mysql_fetch_array($query))
{
extract($row);

echo "<tr>n"
."<td>$gameID</td>n"
."<td>$title</td>n"
."<td>$genre</td>n"
."<td>$platform</td>n"
."<td><a href=?show=$gameID>review</a></td>n"
."</tr>n";

echo "<tr><td colspan=5><hr></td></tr>n";

}
echo "</table>n";

?>

Now what I want to be able to do is to make the review text or any link go to the reivew part of the database without showing the other info. I would like also maybe be able to change the other links to show things according to platform | genre etc.. But I want to start off being able t show off the review. I know this is similar to a weblog but in the books I have it's all date based and I want it ot be ID based.

Reply With Quote
  #2  
Old August 6th, 2002, 01:08 AM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to russ Send a message via Yahoo to russ
RE: Need some simple help

u want something like this?

http://gmflp.l33t.ca/album.php

Reply With Quote
  #3  
Old August 6th, 2002, 06:49 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Need some simple help

Yeah similar to that..

Reply With Quote
  #4  
Old August 6th, 2002, 07:26 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Need some simple help

First of all you might be better off if you had a ssecond table called review with three fields id - gameid - review, but this is a different matter.

To do what you are trying to do all you need to do is put your main content in an if statement
php Code:
Original - php Code
  1.  
  2. if (!isset($show)){
  3. // main content
  4. } else {
  5. $query = "SELECT review FROM games WHERE gameID = '$gameID'";
  6. $sql_result = mysql_query($query) or die(mysql_error());
  7. while ($row = mysql_fetch_array($sql_result)) {
  8. extract($row);
  9. // display review
  10. } // end while
  11.  
  12. } // end else
  13.  


Reply With Quote
  #5  
Old August 7th, 2002, 09:16 AM
MAbans MAbans is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: San Diego CA USA
Posts: 217 MAbans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to MAbans Send a message via Yahoo to MAbans
RE: Need some simple help

I'm still not understanding it. Let me play with it to see. I'm sure I'm just a moron. Oh yea and I created another table like you suggested.

Reply With Quote
  #6  
Old August 7th, 2002, 12:36 PM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Need some simple help

What I was trying to show you was how to display the review once a link has been clicked. The first time you go to the page $show is NULL and/or not set so the code will display your table full of games. Once you click a link the link would set $show and the main content would not be displayed only the review section. The if statement just determines what content to display. Either the main content or a specific review depending on whether or not show is set.

If you have a second table then you would bring back the review with a different query.

Hope this helps,
B


Reply With Quote
  #7  
Old August 7th, 2002, 06:50 PM
MAbans MAbans is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: San Diego CA USA
Posts: 217 MAbans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to MAbans Send a message via Yahoo to MAbans
RE: Need some simple help

I got a better understanding. I'll try it out..

Reply With Quote
  #8  
Old August 7th, 2002, 09:29 PM
MAbans MAbans is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: San Diego CA USA
Posts: 217 MAbans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to MAbans Send a message via Yahoo to MAbans
RE: Need some simple help

ok this is what I did. Using the old 1 table method i coded it like so:
php Code:
Original - php Code
  1.  
  2. if (!IsSet($show))
  3.     {
  4.   $sql = "SELECT * FROM games";
  5.   $query = mysql_query($sql)
  6.      or die ("could not excute the quiery you requested");   
  7.   while ($row = mysql_fetch_array($query))
  8.             {
  9.                 extract($row);
  10.     echo "<tr bgcolor=#FFFFFF align=center>n"
  11.     ."<td>$gameID</td>n"
  12.     ."<td>$title</td>n"
  13.     ."<td>$genre</td>n"
  14.     ."<td>$platform</td>n"
  15.     ."<td><a href=?show=$gameID>review</a></td>n"
  16.     ."</tr>n";
  17.             } //ends while
  18.     } // ends if
  19. else
  20.     {
  21.   $sql2 = "SELECT review FROM games WHERE gameID = '$gameID'";
  22.   $query2 = mysql_query($sql2)
  23.   or die ("could not excute the quiery you requested");
  24.    while ($row = mysql_fetch_array($query2))
  25.             {
  26.                 extract($row);
  27.     echo "<tr bgcolor=#FFFFFF>n"
  28.         ."<td>$gameID $review</td>n";
  29.             } // ends while
  30.     } // ends else
  31.  


Is this correct?

My understanding is this. If the Show value isn't set then it should set it so it makes the link. Then after you click it it should have the value set then go to the else portion in the new page displaying the review part of the table as request. I have the actual queris in a conifg file separate but I tried both ways and recieved the same result. Which was when you click the link it displays the tables and everything correctly (in the source code) just no text comes up. So pretty much a blank page. Any input?

Reply With Quote
  #9  
Old August 8th, 2002, 05:44 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Need some simple help

You are calling the variable $show in the URL but looking for the variable $gameid in the SQL. Change the SQL to $sql2 = "SELECT review FROM games WHERE gameID = '$show'";

Reply With Quote
  #10  
Old August 8th, 2002, 09:36 AM
MAbans MAbans is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: San Diego CA USA
Posts: 217 MAbans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to MAbans Send a message via Yahoo to MAbans
RE: Need some simple help

I had figured it out before. I do have another question? Why is it better, to have 2 tables as opposited to 1? What are the benefits?

Reply With Quote
  #11  
Old August 8th, 2002, 07:21 PM
MAbans MAbans is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: San Diego CA USA
Posts: 217 MAbans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to MAbans Send a message via Yahoo to MAbans
RE: Need some simple help

i understand that, just want hear about people that have had full on experience with MySQL. Sometimes books can be not too practical

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Need some simple help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar&