Page 1 of 1

New coder, some dynamic page questions

Posted: Sat May 23, 2009 1:25 pm
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.

Re: New coder, some dynamic page questions

Posted: Sat May 23, 2009 2:01 pm
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.

Re: New coder, some dynamic page questions

Posted: Sat May 23, 2009 2:19 pm
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.

Re: New coder, some dynamic page questions

Posted: Sat May 23, 2009 2:46 pm
by mortona
Should I be using ajax? Have an onlcick function to post the variable?

Re: New coder, some dynamic page questions

Posted: Sat May 23, 2009 4:52 pm
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

Re: New coder, some dynamic page questions

Posted: Sun May 24, 2009 1:50 pm
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.