links update dynamic data

This is a discussion on "links update dynamic data" within the PHP Forum section. This forum, and the thread "links update dynamic data are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Aug 23rd, 2007, 03:49
Junior Member
Join Date: Jul 2005
Location: Lethbridge, Alberta
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy links update dynamic data

I'm not exactly sure what this is called, so it's hard to do a search on it.

What I'm trying to do is have a webpage that updates the dynamic data from a database based on what links are chosen on the left side of the page.

- On one side of the page is a list of links. (ie: potato, carrot, apple...)

- On the other side of the page is a bunch of dynamic data that connects to a MySQL database.

Depending on what is chosen on the left side of the page, it will show the user that information from the database on the right side.
Example:
If you click on the apple link, it pulls the apple row out of the database and presents a picture of an apple, gives some information on an apple, etc.

I don't think this is very hard but I don't see it in any of the books I have, and have never done it before. Can someone help point me in the right direction or tell me how this is done?

BTW.. I'm using Dreamweaver

Thanks,
Josh
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Aug 23rd, 2007, 03:53
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: links update dynamic data

I'm pretty sure this has to be done with ajax.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Aug 23rd, 2007, 04:00
Junior Member
Join Date: Jul 2005
Location: Lethbridge, Alberta
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Re: links update dynamic data

really? I figured each link would have to pass some information (ie: record number) and then each dynamic data from a recordset would be shown.

see "i think" I have an idea of what needs to be done... I'm just not exactly sure how to do it.

so would it really have to done with ajax?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Aug 23rd, 2007, 04:16
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: links update dynamic data

hmm, if there is a lot to load,
ajax would probably be better.
otherwise you might be able to do something like this:
have three divs
<div id="potato">
grab mysql data here
</div>

<div id="carrot">
grab mysql data here
</div>

<div id="tomato">
grab mysql data here
</div>

for each of these IDs set the visibility to hidden,
then use javascript to show them,
the links on the left would have the onclick attribute:
onclick="showCarrot()"
onclick="showPotato()"
onclick="showTomato()"

and these functions would be something like:
function showCarrot() {
document.getElementById('carrot').style.visibility = 'visible';
}


Obviously, it's more complicated than that though
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Aug 23rd, 2007, 09:26
Reputable Member
Join Date: Feb 2006
Location: London
Age: 26
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Re: links update dynamic data

You won't need ajax to do this, just php.

Do you know any php at all, how to connect to a database and retrieve data for example?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Aug 23rd, 2007, 12:00
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: links update dynamic data

Yeah ... are you talking about link like

domain.com/page.php?something=carrot

? Then ... that's php.

On that page.php you would have something like

PHP: Select all

<?
$something 
$_GET['something'];

.... and 
here you would query your database with the $something in the where clause
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Aug 23rd, 2007, 15:59
Junior Member
Join Date: Jul 2005
Location: Lethbridge, Alberta
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Re: links update dynamic data

To answer a one major question, yes I have my website connected to a database. And yes I have pulled from it before. But normally when I do things like that it's been simple things such as a random quote generator type application or a repeat region spanning over a couple pages presenting items.
Maybe I should have nixed my apple\potato\carrots example since I think back and figure that was a stupid example and it's confusing me a little.

What I'm doing is working on a small Alumni website, and this one page is a little confusing since I haven't done anything like it before.
The idea is that one side of the book lists everyone's name. The other side of the book has the dynamic data links that will show things like persons picture, name, location, email, family, occupation, etc, etc, etc. And this will change depending on the persons name they click on.

I think I understand that I need to have a persons name a link with $autonum (where the number corrosponds to that row of their info in the database)
But on the other side of the page where the information is to be displayed.... I guess where I'm really getting lost is how to pass that information to the other side.
There will be approximately 50 people listed, and I'm afraid of having do a 50 long IF Statement.

So on name side I would have people listed like this?
[code]
domain.com/page.php?person=1
domain.com/page.php?person=2
domain.com/page.php?person=3
domain.com/page.php?person=4
[code]
Now on the other side I would have to create a RecordSet to have something similar to this:
[code]
$person = $_GET['person'];
$query_Recordset1 = "SELECT picture, name, email, occupation FROM people_database WHERE person='$person'");
[code]

Sorry I'm at work right now and can't test it out, so I'm trying to make sure I get it right before I go home.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Aug 23rd, 2007, 21:34
Reputable Member
Join Date: Feb 2006
Location: London
Age: 26
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Re: links update dynamic data

Your almost there

After you have the data from the database you just need to print it out:

Code: Select all
$row = mysql_fetch_array($query_Recordset1) or die(mysql_error());
echo 'Name:'.$row['name'].'<br />';
echo 'Email:'.$row['email'].'<br />';
Give it a go, and post your code if you can't get it to work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Aug 24th, 2007, 05:07
Junior Member
Join Date: Jul 2005
Location: Lethbridge, Alberta
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Re: links update dynamic data

Thanks Jimz. You've been a big help!!!

ok, so playing around with it tonight I finally have it figured out. Apparently I found after testing it out that you cannot use the same name as the field you are ultimately trying to call.
What I mean is if your table column is called auto.... don't call the parameter auto throughout. It just doesn't like you very much if you do.

I thought I would post my code for those that are interested.

The upper code before the <head> starts
Code: Select all
<?
mysql_select_db($database_test, $test);
$something = $_GET['num'];
$query_Recordset1 = "SELECT auto, image, `desc`, `comment` FROM test WHERE auto='$something'";
$Recordset1 = mysql_query($query_Recordset1, $test) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
The links that call the specific row in the table
Code: Select all
<p><a href="test.php?num=1">Set 1</a></p>
<p><a href="test.php?num=2">Set 2</a></p>
<p><a href="test.php?num=3">Set 3</a></p>
<p><a href="test.php?num=4">Set 4</a></p>
And finally the code that displays the 3 items based upon the 'auto' field
Code: Select all
<p><img src="<?php echo $row_Recordset1['image']; ?>" /></p>
<p>&nbsp;<?php echo $row_Recordset1['desc']; ?></p>
<p>&nbsp;<?php echo $row_Recordset1['comment']; ?></p>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Aug 24th, 2007, 16:29
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: links update dynamic data

Glad you got it working in the end
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
database, dynamic data, links, php

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Submit Free the best top Web Directories with over 6500 links (update PR and Alexa) ronaldo30 Search Engine Optimization (SEO) 1 Jul 4th, 2008 12:22
coldfusion: dynamic links for every occurance lockmac Other Programming Languages 1 Feb 20th, 2008 12:16
Dynamic links not working in Flash? edd_jedi Flash & Multimedia Forum 2 May 18th, 2007 18:25
dynamic data in a table gecko Web Page Design 3 May 6th, 2007 11:47
VB: Datagrid Update Query - Data Dissapering DJ1UK ASP.NET Forum 2 Aug 8th, 2005 12:36


All times are GMT. The time now is 00:17.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42