New coder, some dynamic page questions

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
mortona
Forum Newbie
Posts: 4
Joined: Sat May 23, 2009 1:18 pm

New coder, some dynamic page questions

Post by mortona »

I'm Andrew, from UW Seattle. I have several n00b questions to embarrass myself with:

I'm making a page that can display different items in the same page format.

I think the way it works, is that links are post commands that pass the id, which is used to query the database?

How do I do that? Do I simply put the id in the link, then parse it into a sql statement?
Or can i do a post command in onclick?

Can you show/point me to some code that does this? Thanks.
anand
Forum Commoner
Posts: 80
Joined: Fri May 22, 2009 11:07 am
Location: India
Contact:

Re: New coder, some dynamic page questions

Post by anand »

mortona wrote:I'm Andrew, from UW Seattle. I have several n00b questions to embarrass myself with:

I'm making a page that can display different items in the same page format.

I think the way it works, is that links are post commands that pass the id, which is used to query the database?

How do I do that? Do I simply put the id in the link, then parse it into a sql statement?
Or can i do a post command in onclick?

Can you show/point me to some code that does this? Thanks.
You can use a while loop.
mortona
Forum Newbie
Posts: 4
Joined: Sat May 23, 2009 1:18 pm

Re: New coder, some dynamic page questions

Post by mortona »

Code: Select all

 
while (WHAT GOES HERE??)
{
$id = //parse from href
select * from blah where id = $id
// put results where they need to go
}
 
Something like this?? How do I read the address? What are the conditions of the while loop?

Thanks for your help.
Last edited by Benjamin on Tue May 26, 2009 10:26 am, edited 1 time in total.
Reason: Changed code type from text to php.
mortona
Forum Newbie
Posts: 4
Joined: Sat May 23, 2009 1:18 pm

Re: New coder, some dynamic page questions

Post by mortona »

Should I be using ajax? Have an onlcick function to post the variable?
Scriptor
Forum Newbie
Posts: 9
Joined: Fri May 22, 2009 12:27 am

Re: New coder, some dynamic page questions

Post by Scriptor »

for us to help you, please read php manual first..

start with variables, then mysql, while, array.... and so forth. You showed no code, your are working from nothing?

bsically I would do it like this..

Code: Select all

 
$query=mysql_query("Select * from sometable where id='$_GET[id]'");
while($row=mysql_fetch_array($query)){
//do your list
}
 
bang bing bara boom
Last edited by Benjamin on Tue May 26, 2009 10:27 am, edited 1 time in total.
Reason: Added [code=php] tags.
mortona
Forum Newbie
Posts: 4
Joined: Sat May 23, 2009 1:18 pm

Re: New coder, some dynamic page questions

Post by mortona »

I understood how to put stuff on the page from the database. I was trying to figure out how to pass a variable from a link to $_GET['id']. Simple (now :banghead: ): put index.php?id=adsf123 in the href tag.

Thanks for looking, I'll be back with more dumb q's later.
Post Reply