Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] How to set a variable to a link?


[SOLVED] How to set a variable to a link?

Reply
  #1 (permalink)  
Old 11-06-08, 03:07 AM
tanermacit tanermacit is offline
Newbie Coder
 
Join Date: Sep 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] How to set a variable to a link?

Hello again;
How to set a variable to a link?

i am programming an online examination project.
PHP Code:

  <?

//all variables come from a form except questionid 
$result mysql_query("SELECT imgquestionurl FROM exam where class='6' and examid='1'and lesson='1' and questionid='1' ;");
$row mysql_fetch_row($result);
?>
      <img src="../gununsorusu/upload/<? echo $row[0]; ?>" align="middle"></img>  </p>
Think that there are links as below
1 2 3 4 5 6 7 8 9

when a user click 2; user must see the second question.So how can i set a variable to this link for to see question?

You can see my problem at the attachment image.
Attached Images
File Type: gif aa.GIF (19.3 KB, 67 views)
Reply With Quote
  #2 (permalink)  
Old 11-06-08, 07:42 AM
landing's Avatar
landing landing is offline
Coding Addict
 
Join Date: Jul 2006
Location: Scotland
Posts: 302
Thanks: 0
Thanked 0 Times in 0 Posts
Fairly easily

Generate your links in a similar manner
HTML Code:
<a href="questions.php?question_id=1">1</a>
<a href="questions.php?question_id=2">2</a>
<a href="questions.php?question_id=3">3</a>
questions.php
PHP Code:

$result mysql_query("SELECT imgquestionurl FROM exam where class='6' and examid='1'and lesson='1' and questionid='$_GET[question_id]' ;"); 

$row mysql_fetch_row($result); 
That is the general idea. Pass the question ID through the URL using $_GET for each question link, then using this question ID to fetch the question from the database.
__________________
Always sanitise your data


Best regards

Last edited by landing; 11-06-08 at 07:45 AM.
Reply With Quote
  #3 (permalink)  
Old 11-06-08, 10:59 AM
tanermacit tanermacit is offline
Newbie Coder
 
Join Date: Sep 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
well thanks alot this is really great.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Six Sites Exchanging Links! - PR3+ Web Hosting, Web Design, Entertainment & Career coffeecoder General Advertisements 0 10-10-05 12:52 AM
Looking - variable value X set value X set value = wayne m Script Requests 1 09-17-05 04:12 PM
Xml / Dom / Css Mark_SC.SE JavaScript 0 06-29-05 08:05 AM
ASP upload prob minority ASP 1 06-27-05 08:35 AM
Passing a table or variable through a link? chinablack1480 PHP 1 12-07-03 03:55 AM


All times are GMT -5. The time now is 08:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.