Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populating form from sql

Status
Not open for further replies.

puremm

Technical User
Oct 30, 2006
23
GB
I have a form with seven categories, each has a title and a answer, but one has three answers and another two... I have the data stored in a table, each entry is identified by a entry_no.

I want to get each category and display them in the form here's the code I'm using at present;

$entry_uid = 12340001

$msql = " SELECT category,entry_title,entry_file_1,entry_file_2,entry_file_3,entry_uid FROM entry_categories WHERE entry_uid = '$id' ";
$qry = mysql_query($msql);


while ($cat = mysql_fetch_assoc($qry)) {

if ($cat['category'] == '1') {
echo '<label class="field-entry">
1. Exclusive News/Sports Story of the Year (title)<input type="text" name="" value="'. $cat['entry_title'] .'" disabled /></label>
<label class="field-upload1">Select story file (any .doc, .docx, .txt, .rtf format)<input type="text" name="" value="'. $cat['entry_file_1'] .'" disabled="disabled" /></label>';
} else {
echo '<label class="field-entry"><input type="hidden" name="Cat_1" value="1" />
1. Exclusive News/Sports Story of the Year (title) <input type="text" name="Title_1" value="" /></label>
<label class="field-upload1">Select story file (any .doc, .docx, .txt, .rtf format) <input type="file" name="File_1_1" value="" /></label>';
}

if ($cat['category'] == '2') {
echo '<label class="field-entry">
2. Spec News/Sport Story of the Year (title) <input type="text" name="" value="'. $cat['entry_title'] .'" disabled /></label>
<label class="field-upload1">Select story file (any .doc, .docx, .txt, .rtf format)<input type="text" name="" value="'. $cat['entry_file_1'] .'" disabled="disabled" /></label>';
} else {
echo '<label class="field-entry"><input type="hidden" name="Cat_1" value="1" />
2. Spec News/Sport Story of the Year (title) <input type="text" name="Title_2" value="" /></label>
<label class="field-upload1">Select story file (any .doc, .docx, .txt, .rtf format) <input type="file" name="File_2_1" value="" /></label>';
}
 
first off, please post code within [ignore]
Code:
[/ignore] tags. it makes it enormously easier to read.

secondly, can you explain what the difference is between cat 1 and 2? so far as I can see from your code if something is cat 2, then the else of cat 1 is executed and THEN the if true condition of the second conditional is fired off. If something is cat 2 then vice versa. and if something is cat something else then the else's of both conditionals are fired. is this really your intention?
 
Category (cat) is basically a number for a criteria

So in total there are seven categories, each requiring a title and a file (of text) to be uploaded...
 
could you answer my question? is the behaviour that i set out above representative of your intention?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top