Closed Thread Icon

Topic awaiting preservation: Dynamic pages in PHP or ASP (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=26749" title="Pages that link to Topic awaiting preservation: Dynamic pages in PHP or ASP (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Dynamic pages in PHP or ASP <span class="small">(Page 1 of 1)</span>\

 
spramod
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Sep 2005

posted posted 09-29-2005 16:47

Please help!

I am designing a website (dynamic) (I m not too experienced!!)
This website has different management courses.
eg.
management1.html
management2.html

so on..
in each of these pages, i have a link for "Book This Course"

As i click on book a course in management.html it should display automatically the name of that course.
I do not want to create 'n' book this course pages.
i want dynamic links for book a course..
bookcourse.asp?id=397
bookcourse.asp?id=399
how do i do this??
kindly helpp..
thanks a ton!!!

Veneficuz
Paranoid (IV) Inmate

From: A graveyard of dreams
Insane since: Mar 2001

posted posted 09-29-2005 18:07

Not really sure what you want, but...

I would think that the easiest way to do that would be to create an array on the 'bookcourse.asp' page that holds all the titles, and then use the id passed in the url to get the right entry from the array. In php that might look something like

code:
$titles = ('foobar', 'google', 'all your base');

/* and now print the correct title depending on the id variable passed*/
print $titles[ $_GET['id'] ];


Never touched asp, so don't know how it would look there

You might also want to check out the tutorial sections in our FAQ and those over at the Gurus network.

_________________________
"There are 10 kinds of people; those who know binary, those who don't and those who start counting at zero"
- the Golden Ratio - Vim Tutorial -

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 09-30-2005 14:41

Well, I suspect you're going to need to retrieve more info about the course in order to book it, so I would likely do something with a MySQL database:

$sql = "select * from courses where id = '$id' limit 1";
$results = mysql_query($sql);
while ($rows = mysql_fetch_array($results)){
// do stuff here
}

you could also do something with a PHP switch if you don't have a ton of data to deal with.

I like Veneficuz's method as well.

spramod
Obsessive-Compulsive (I) Inmate

From:
Insane since: Sep 2005

posted posted 09-30-2005 16:37

Thanks a lot for ur suggestions,
can u please guide me further..



<!------ bookcourse.php -------->

<table ......
<?php

$result=mysql_query("select * from links where category_id=1 and link_id=1");
$numrows=mysql_num_rows($result);

for($i=0;$i<$numrows;$i++)
{
$fetchrow=mysql_fetch_row($result);
$text=$fetchrownumber2;
$link=$fetchrowStrezz;
$link_id=$fetchrow[0];



?>
<td background="images/artical-middle-curve2.gif" class="body-text"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="2%">&nbsp;</td>
<td width="98%" class="body-text"><?php echo($text);?></td>
</tr> </table></td>


<?php
}
?>

<!---- this is the code i have managed to write,,, it works with link_id=1,,

can u please tell me how to put and if - else statement here ...

eg:

if if ($link_id=1)
$result=mysql_query("select * from links where category_id=1 and link_id=1");
$numrows=mysql_num_rows($result);
......


this is not working..
it gives me parse error coz i used if--else..
Parse error: parse error, unexpected T_ELSE

kindly helpp...
thanks a ton....

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-30-2005 17:44

if ($link_id==1) { // Notice the second equal sign otherwise this will always return true
$result=mysql_query("select * from links where category_id=1 and link_id=1");
$numrows=mysql_num_rows($result);
} else {
// Do something else.
}



.:[ Never resist a perfect moment ]:.

spramod
Obsessive-Compulsive (I) Inmate

From:
Insane since: Sep 2005

posted posted 09-30-2005 18:08

can u please tell me where to put the else statement, coz i m using else after

code:
<?php 
 if ($link_id=="1") {
$result=mysql_query("select * from mtc_links where category_id=1 and mtclink_id=1"); $numrows=mysql_num_rows($result);
}

elseif ($link_id=="2"){

$result=mysql_query("select * from mtc_links where category_id=1 and mtclink_id=2");
$numrows=mysql_num_rows($result);}											  								  
for($i=0;$i<$numrows;$i++)
 {
 $fetchrow=mysql_fetch_row($result);
$text=$fetchrow[2];
 $link=$fetchrow[3];
 $link_id=$fetchrow[0];
																					  
											 										 ?>
                                        <td background="images/artical-middle-curve2.gif" class="body-text"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr> 
                                              <td width="2%">&nbsp;</td>
                                              <td width="98%" class="body-text"><?php echo($text);?></td>
                                            </tr> </table></td>
											
                                      
                                      <?php
			}
   		?>


coz it gives me an error that parse error - unexpected else..

i used second equal sign as well...
please can u correct this code...
thanks a ton... great support out here...

(Edited by bitdamaged on 09-30-2005 18:19)

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-30-2005 18:17

Not sure where your error is but you can use variables in your sql and in this case get rid of the if/elseif altogether.

select * from links where category_id=1 and link_id=$link_id"


But you want to validate them first if you are using user input to protect from a sql injection attack.


so do something like this:

code:
$link_id = trim($link_id) // Get rid of any white space

if ( is_int($link_id ) ) {  // Make sure our link id is an integer
$result = .... / all the rest.

} else {
echo "Invalid Link ID";
}



(Also using the code tag will keep you from inserting unwanted UBB references where your arrays are)



.:[ Never resist a perfect moment ]:.

spramod
Nervous Wreck (II) Inmate

From:
Insane since: Sep 2005

posted posted 09-30-2005 18:42

i will not be using any user input,,

i managed to solve the problem and its working..
with
get($link_id)

*** i need help with other part ****

i will be using upto $link_id = 100

they are just links and no use inputs..

how do u use the code, coz if-else gets too long...
for each course, i have to use if-else..
so what is the other option,,
so please suggest...
thanks a ton

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-30-2005 19:35

First if you are using links like

bookcourse.php?id=433

Then you're using user input (or a user modifiable value).

Not sure of your question, my answer above would get rid of the if / else for different link_ids



.:[ Never resist a perfect moment ]:.

spramod
Nervous Wreck (II) Inmate

From:
Insane since: Sep 2005

posted posted 10-01-2005 08:30

thanks a ton,
i tried

$link_id=trim($link_id) // Get rid of any white space

if ( is_int($link_id ) ) { // Make sure our link id is an integer
$result = .... / all the rest.

} else {
echo "Invalid Link ID";
}

/// here i made sure $link_id is an integer..
but i keep getting the output "invalid link id"
i thnk the $link_id value is not being passed here. if so, how do i do it..
i m not sure if i m getting it right..

thanks once again..

« BackwardsOnwards »

Show Forum Drop Down Menu