Database - CPanel

Please support our Database Design advertiser: $6.99 Domain Names at 1&1. Includes Free Privacy. Save Now!
Thread Solved

Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #51
Sep 1st, 2009
Actually a more personal example..on my site, I have data show of the name and the description of the achievement. Well each name represents a new achievement. I want to be able to take one specific achievement and show only that just as I show only one table from the database right now. For example, on http://www.wowtah.com/achievements.php?type=general the first achievement is "Level 10". I want the user to be able to click on the achievement and just as the tables do, the info changes to whatever I want it to show then. Does that make sense? So that I could have a section that explains how to gain the achievement, granted, this one in particular doesn't need much explaining.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,085
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 179
Sponsor
pritaeas's Avatar
pritaeas pritaeas is online now Online
Veteran Poster

Re: Database - CPanel

 
0
  #52
Sep 2nd, 2009
It would be something like this. I assume you have a column 'id' in your tables that identifies each separate record.

  1. <table>
  2. <?php
  3. $db_link = @mysql_connect('localhost', 'username', 'pass') or die(mysql_error());
  4. @mysql_select_db('wowtahc1_achievements') or die(mysql_error());
  5.  
  6. $id = isset($_GET['id']) ? $_GET['id'] : 0;
  7.  
  8. $type = $_GET['type'];
  9. switch ($type)
  10. {
  11. case 'general': {
  12. if ($id < 1)
  13. {
  14. $query = 'SELECT * FROM general';
  15. $result = @mysql_query($query) or die(mysql_error());
  16. if ($result)
  17. {
  18. while ($row = mysql_fetch_assoc($result))
  19. {
  20. echo '<tr>';
  21. echo '<th class="title"><a href="achievements.php?type=general&id=' . $row['Id'] . '">' . $row['Name'] . '</a></th>';
  22. echo '<td class="description">' . $row['Description'] . '</td>';
  23. echo '</tr>';
  24. }
  25. mysql_free_result($result);
  26. }
  27. }
  28. else
  29. {
  30. $query = "SELECT * FROM general WHERE id=$id";
  31. $result = @mysql_query($query) or die(mysql_error());
  32. if ($result)
  33. {
  34. if ($row = mysql_fetch_assoc($result))
  35. {
  36. echo '<tr>';
  37. echo '<th class="title">' . $row['Name'] . '</th>';
  38. echo '<td class="description">' . $row['Description'] . '</td>';
  39. echo '</tr>';
  40. }
  41. mysql_free_result($result);
  42. }
  43. }
  44. break;
  45. }
  46. case 'quests':
  47. {
  48. if ($id < 1)
  49. {
  50. $query = 'SELECT * FROM quests';
  51. $result = @mysql_query($query) or die(mysql_error());
  52. if ($result)
  53. {
  54. while ($row = mysql_fetch_assoc($result))
  55. {
  56. echo '<tr>';
  57. echo '<th class="title"><a href="achievements.php?type=quests&id=' . $row['Id'] . '">' . $row['Name'] . '</a></th>';
  58. echo '<td class="description">' . $row['Description'] . '</td>';
  59. echo '</tr>';
  60. }
  61. mysql_free_result($result);
  62. }
  63. }
  64. else
  65. {
  66. $query = "SELECT * FROM quests WHERE id=$id";
  67. $result = @mysql_query($query) or die(mysql_error());
  68. if ($result)
  69. {
  70. if ($row = mysql_fetch_assoc($result))
  71. {
  72. echo '<tr>';
  73. echo '<th class="title">' . $row['Name'] . '</th>';
  74. echo '<td class="description">' . $row['Description'] . '</td>';
  75. echo '</tr>';
  76. }
  77. mysql_free_result($result);
  78. }
  79. }
  80. break;
  81. }
  82. }
  83. mysql_close($db_link)
  84. ?>
  85. </table>
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #53
Sep 7th, 2009
Thanks again priteas. I am sure that code will work excellently. I just haven't had a chance to have a go with it. Been so busy with school and work I'm finally now replying to you.

So. I do have another question. I added another field to my database, a blob type like you told me to use for pictures. I attached the picture and then I tried having that also show up on my site and it turned everything into mumbo jumbo. Is there some special way you add a blob field? Do I gotta do something different than I do with these varchar type fields? Here is what the part of my code that I edited looked like:

case 'general': {
      $query = 'SELECT * FROM general';
      $result = @mysql_query($query) or die(mysql_error());
      if ($result)
      {
      while ($row = mysql_fetch_assoc($result))
      {
      echo '<br/>' . '<br/>';
      echo $row['Picture'] . '<span class="title">' . $row['Name'] . '</span>';
	  echo '<br/>';
	  echo '<span class="description">' . $row['Description'] . '</span>';
      }
      mysql_free_result($result);
      }
      break;
      }

Whats highlighted in red is what I added. Before that, everything works fine. I even tried replacing 'Name' with 'Picture' just to see if I added the php wrong, but, still same problem. Um, and I guess to make it easier to see what issue is MAYBE the mumbo jumbo that appeared might be useful....

�PNG  ��� IHDR���@���@����iq���mIDATx�ݛmp[ՙ�֕4W�m�� �`�b�<����4i�����~��t�>v:�~`ٲہ�fg`w��3��NSR�@�`j���1a#GX�*[�Eҽ������x���=���<�9�yιM�,� E�H�ʸ�]�~�)��ݵ�K��^�L�������_}�|� �M(5e��:r����ԧ(���ke�y�Ⱦs@p�x��x�G~�){�C=�@��xפ�@�����8���`�ȭ��xi�%���y�\d�d� �x�!�GF��2��q��F�Qa��+��H��eT�>��x�@�Pѹ����5�\u�)� �CЕ��ߧ��g(5���1�x� �+|؄����:��i�� j�:��gP��ޠ�� *�T̼v*��-$:[��

Thats just a small portion of it, but it all looks basically like that, hehe.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #54
Sep 7th, 2009
lol dont mind the confused smiley in the middle of the mumbo jumbo, it must have had the correct symbols in the correct spot to make that, hahaha.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,085
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 179
Sponsor
pritaeas's Avatar
pritaeas pritaeas is online now Online
Veteran Poster

Re: Database - CPanel

 
0
  #55
Sep 7th, 2009
A blob field is just binary data, which in your code gets displayed as text. The most easy way would be to create a separate php page that retrieves your image and displays it. I have an example of this in my original admin panel. I'll need some time to make an example for you.

This thread has a working example, so hopefully you won't need a demo from me: http://www.phpbuilder.com/board/show...php?t=10252369
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #56
Sep 8th, 2009
Ok. Um. Yea, that code is a little more confusing looking. Could you maybe explain it a little better than that guy? Cuz I did what he said...but..nothing happened other than I got this on my page:

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/wowtahc1/public_html/achievements.php on line 7
">

Line 7 is:

<img src="showavatar.php?id="<?php echo mysql_result($avatardetail, 0, "ID"); ?>">

now I realize it could be because of $avatardetail cuz that could be something from the guy's database but I dont know the equivilence of it to mine. I did name the .php I put the code in called showavatar.php for the sake of simplicity for now so I know that isn't the issue.

But, I don't think that's the only issue we will run into so, lets also solve some others. Here is the code I put in, (for the sake of showing you my changes trying to get it to function with my database):

<?php
require("tools.php");
if(isset($id))
{
    $filedata = mysql_query("SELECT * FROM general WHERE ID = '".$id."' LIMIT 1");
    header("Content-type: \"".mysql_result($filedata, 0, "filetype")."\"");
// Work out whether we can show or download the attachment:
    $mimetype = explode("/", $row["filetype"]);
    if($mimetype[0] != "Picture")
    {
        header("Content-length: ".mysql_result($filedata, 0, "filesize"));
        header("Content-Disposition: attachment; filename=".mysql_result($filedata, 0, "filename"));
        header("Content-Description: PHP Generated Data");
    }
    echo mysql_result($filedata, 0, "Avatar");
}
?>

I highlighted in red again the changes that I made. I think also I should change "Avatar"? but I dont know to what. Also, I don't see how in this code I can place the image where I want it....

Also, whats tools.php? That code says it requires it and, I can see it on my tabs, it's there, but it's blank.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,085
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 179
Sponsor
pritaeas's Avatar
pritaeas pritaeas is online now Online
Veteran Poster

Re: Database - CPanel

 
0
  #57
Sep 8th, 2009
You can remove the require(tools), it's something from the other guys code.

You shouldn't have changed "image" into "Picture".

I have a very busy week this week, so I haven't got around to making you a demo.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #58
Sep 8th, 2009
Oh its no problem. You take your time. I'm in no hurry.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #59
Sep 8th, 2009
Ok well it's still having a problem with the same line and I still don't understand how I tell it where to put the image.

So whenever you do get a chance to make that demo that would be superb. But like I said before, no rush.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,085
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 179
Sponsor
pritaeas's Avatar
pritaeas pritaeas is online now Online
Veteran Poster

Re: Database - CPanel

 
0
  #60
Sep 22nd, 2009
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 6831 | Replies: 61
Thread Tools Search this Thread



Tag cloud for Database Design
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC