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.
New coder, some dynamic page questions
Moderator: General Moderators
Re: New coder, some dynamic page questions
You can use a while loop.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.
Re: New coder, some dynamic page questions
Code: Select all
while (WHAT GOES HERE??)
{
$id = //parse from href
select * from blah where id = $id
// put results where they need to go
}
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.
Reason: Changed code type from text to php.
Re: New coder, some dynamic page questions
Should I be using ajax? Have an onlcick function to post the variable?
Re: New coder, some dynamic page questions
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..
bang bing bara boom
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
}
Last edited by Benjamin on Tue May 26, 2009 10:27 am, edited 1 time in total.
Reason: Added [code=php] tags.
Reason: Added [code=php] tags.
Re: New coder, some dynamic page questions
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
): put index.php?id=adsf123 in the href tag.
Thanks for looking, I'll be back with more dumb q's later.
Thanks for looking, I'll be back with more dumb q's later.