|
-
Aug 27th, 2002, 04:20 PM
#1
Thread Starter
Member
checkboxes..
My problem is this: I am pulling information from the database and it is stored in a table on the screen. I want to add a checkbox next to each line so that if there are multiple john does in the database the user can decide which john doe he needs to edit by clicking on the checkbox and then clicking submit. Any help would be appreciated. Thanks
Sometimes the simplest things are the hardest...
-
Aug 27th, 2002, 05:01 PM
#2
Stuck in the 80s
What part of this do you need help with?
Make each checkbox an array:
Code:
<input type="checkbox" name="edit[]" value="id_of_record">John Doe 1
<input type="checkbox" name="edit[]" value="id_of_record">John Doe 2
<input type="checkbox" name="edit[]" value="id_of_record">John Doe 3
And in your code for the submit:
Code:
for ($i = 0; $i < count($_REQUEST['edit']); $i++) {
//edit the record
}
-
Aug 27th, 2002, 05:44 PM
#3
Thread Starter
Member
checkboxes
Part of my problem is the checkboxes are appearing at the top of the screen instead of next to the item in the loop. and also, the checkboxes are not all working, only the first one. Ive spent time on and off playing with this and the books that I have are not helpful in this area, thats why I asked you guys. Thanks
Sometimes the simplest things are the hardest...
-
Aug 27th, 2002, 07:02 PM
#4
Stuck in the 80s
Could you post the code you have now so we could help find the problems in it?
-
Aug 28th, 2002, 09:21 AM
#5
Thread Starter
Member
code
this is the piece of code I have been working on:
while ($Row = mysql_fetch_array($Result))
{
print ("<TR Align=center Valign=top>\n");
print ("<TD Align=center Valign=top>$Row[social]</TD>\n");
print ("<TD Align=center Valign=top>$Row[lname]</TD>\n");
print ("<TD Align=center Valign=top>$Row[fname]</TD>\n");
print ("<TD Align=center Valign=top>$Row[address]</TD>\n");
print ("<TD Align=center Valign=top>$Row[state]</TD>\n");
print ("<TD Align=center Valign=top>$Row[Zip]</TD>\n");
print ("<TD Align=center Valign=top>$Row[region_code]</TD>\n");
print ("<TR>\n");
$array[$x] = $Row[social];
$x=$x+1;
<form method="post" action="submitupdateuserinfo.php">
?>
<input type="checkbox" name="cart[]" value=<?$array[x]?>>
<input type="submit" name="b1" value="submit">
</form>
}
print "</table>\n";
<?
what i want to happen is to have the checkboxes print out at the end of each line, becuase what this is doing is querying a database against user input, so for example if i enter in a first 3 digits of my last name, and there are 5 other people in the database whose last names start with the same 3 charachters as mine, it will return 5 names. I want a checkbox after each set of data that I can just click on and have it bring up more information on that particular user. Is what im saying possible? thanks
Sometimes the simplest things are the hardest...
-
Aug 28th, 2002, 11:01 AM
#6
Stuck in the 80s
Re: code
Code:
echo '<form method="post" action="submitupdateuserinfo.php">';
while ($Row = mysql_fetch_array($Result)) {
echo '<TR Align=center Valign=top>
<TD Align=center Valign=top>' . $Row['social'] . '</TD>
<TD Align=center Valign=top>' . $Row['lname'] . '</TD>
<TD Align=center Valign=top>' . $Row['fname'] . '</TD>
<TD Align=center Valign=top>' . $Row['address'] . '</TD>
<TD Align=center Valign=top>' . $Row['state'] . '</TD>
<TD Align=center Valign=top>' . $Row['Zip'] . '</TD>
<TD Align=center Valign=top>' . $Row['region_code']</TD>';
$array[] = $Row['social]';
$x=$x+1;
echo '<TD Align=center Valign=top>
<input type="checkbox name="cart[] value="' . $array[$x] . '"></td>
</tr>';
}
echo '</table><input type="submit"></form>';
-
Aug 28th, 2002, 08:30 PM
#7
Thread Starter
Member
thanks
I was able to get everything to work with the code that you gave me.. if i might ask thouhg.. what do all the periods do? I noticed that was the main differnece between yours and mine? what are they there for? Thanks a lot
Sometimes the simplest things are the hardest...
-
Aug 28th, 2002, 08:49 PM
#8
Stuck in the 80s
The . is the string concatenator. So:
Code:
$var1 = "cunch";
echo "Varable #1 = " . $var1 . "<br>";
Will out put "Variable #1 = cunch<br>"
If you use double quotes, though, you can just do:
Code:
$var1 = "cunch";
echo "Variable #1 = $var1<br>";
It's just my coding preference.
-
Aug 28th, 2002, 10:01 PM
#9
Thread Starter
Member
coding
Cool, thanks for the info... the code that you gave me makes a lot more sence to me now.
Sometimes the simplest things are the hardest...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|