Jump to content

Check Box Next to Mysql Query


Deanznet

Recommended Posts

How would one go about submitting check box data to mysql database.

 

// Retrieve all the data from the table
$result = mysql_query("SELECT * FROM phpbb_adr_shops_items WHERE item_owner_id = '1' ")
or die(mysql_error());  
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";

 

That gets all the stuff in that table.. I want to know how to get check box their and have a drop list box i guess with Different options Ex. Buy or Sell

 

I would have to use a loop for this because i have more than 1 item in the table and i prob will always add more.

 

Will it have to have the item id from the mysql table.. because i have a table that has the item id in it also.

 

Link to comment
Share on other sites

This might work. I change fetch row to fetch assoc so you can use the col name to call it. You shouldn't need the foreach loop

<?php
// Retrieve all the data from the table
$result = mysql_query("SELECT * FROM phpbb_adr_shops_items WHERE item_owner_id = '1' ")
or die(mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print '<form action="" method="post"><table width=200 border=1>'."\n";
while ($get_info = mysql_fetch_assoc($result)){
print "<tr>\n";

print "\t<td><font face=arial size=1/>";
print '<input type="chechbox" name"somename" />'.$get_info['col_name1'].'</font></td>\n';
print '<input type="chechbox" name"somename" />'.$get_info['col_name2'].'</font></td>\n';
print '<input type="chechbox" name"somename" />'.$get_info['col_name3'].'</font></td>\n';
print "</tr>\n";
}
print "</table></form>\n";

?>

Link to comment
Share on other sites

That was weird it should a whole bunch of blank text box with nothing in it Lol

 

I need to to also display the items in the table.. Each item has a description and a price so it look like this

 

 

X- represents check box

 

X item name  Item Description Price Picture

X item name  Item Description Price Picture

X item name  Item Description Price Picture

 

list box submit

 

Also im not sure how to do this 100% but when i hit submit im going to have it post to a file and depending on what was selected. lets say buy was selected it will change subtract the price from their cash and than also update the owner name and the change item in show from 1 to 0. because each item has fields in the database such as Item id, item owner, Item price, Item Desc Item in Shop etc..

 

So if you know how to do this if you can explain

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.