Jump to content

Working With Two Tables


justlukeyou

Recommended Posts

I am entering a question and notes into one table and creating an ID number in Table 1:

 

$qid (Question ID)

$question

$notes

 

I am then entering an answer and creating an ID for the answer which sites next to question ID in Table 2:

 

$aid (Answer ID)

$answer

 

I am now trying to transfer the Question ID into Table 2.

 

I am currently trying to do this as a hidden string:

 

<input name="category" type="hidden" value="$qid" id="qid" >

 

Does any one have any advice on how I can use two fields. 

 

Can I display or insert data with the same php script?

Link to comment
Share on other sites

Hi,

 

I've now got this working and its not an issue of two tables.  But Im now stuck on entering a string in a hidden value in a form.

 

I am trying to transfer $qid as a hidden value in a form.  Does anyone know if this is possible?

 

$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))

{
$category = $row['category'];
$notes = $row['notes'];
$question = $row['question'];
$qid = $row['qid'];

echo "
<a href= 'http://www.ukhomefurniture.co.uk/test/homesoeasy/question.php?question=$qid'>$question </a></br>
$notes</br> 
category: <a href= 'http://www.ukhomefurniture.co.uk/test/homesoeasy/category.php?category=$category'>$category</a></br></a></br>
Question ID: $qid </br>";
}


// close connection 
mysql_close();



?>

<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="phpviewanswerquestion.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3"><strong>Your Answer</strong></td>
</tr>
<tr>
<td width="71">Answer</td>
<td width="6">:</td>
<td width="600" height="50"><input name="answer" type="text" id="answer"></td>
<tr>
<td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td>
<input name="ansqid" type="hidden" value=" <?php $qid ?>" id="ansqid" >
</tr>
</table>
</form>
</td>
</tr>
</table>

Link to comment
Share on other sites

I have $qid on one page and I am trying to post it to another page via a hidden type

 

This doesn't work

 

<input name="ansqid" type="hidden" value=" <?php $qid ?>" id="ansqid" >

 

or

 

<input name="ansqid" type="hidden" value="$qid" id="ansqid" >

 

but this does

 

<input name="ansqid" type="hidden" value="123456789" id="ansqid" >

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.