Jump to content

how to get the value of each input of each data I bring from the db?


yami

Recommended Posts

Hello ..I tried to bring some items from database and display them one by one on the screen..I put an input for each item I got from db ..my question is how can I get the value of each input of each item displayed on the screen?If anyone wants the code here it is:

<?php
$bringitem = $connection->query("SELECT * from item where idItem='$iditemm'");
			    if(!$bringitem){
				   echo mysqli_error($connection);
			    }
				while($rowww = $bringitem->fetch_assoc()) {
?>
<td>
	 <?php echo $rowww['itemName'];?>
</td>
<td>
  <form action="">
   <input type="number" id="quantity" name="quantity" min="1" max="50" style="width:3em;">
  </form>
</td>
<?php
                }
?>

Note : I am trying to get them all by one submit button

Edited by yami
Link to comment
Share on other sites

23 minutes ago, yami said:

Note : I am trying to get them all by one submit button

You say all but only select a single item. And you don't have a submit button!

Where is the $iditemm value coming from?

24 minutes ago, yami said:

how can I get the value of each input

No idea - where is it supposed to come from?

Link to comment
Share on other sites

Here's the code?   What code?  A bit of something from somewhere that has no resemblance to what you are asking "how to do" is all this is.

You say you want to display the results of a query but you show one data field.   

You seem to be wanting to display it in an html table format but you don't know how to write one.  And why exactly are you using input tags to 'display' your data?  You don't say anything about doing an update.

Now here is what your code looks like when written in a meaningful way so that you can see what you should really see:

$bringitem = $connection->query("SELECT * from item where idItem='$iditemm'");
if(!$bringitem)
{
	echo mysqli_error($connection);
	exit();	//  Seem to have failed so why continue on?
}
while($rowww = $bringitem->fetch_assoc()) 
{
	//  Let's show an item in a table but let's 
	//  not start a table nor start a row for that table
	//  And let's even put that item in a form but don't plan on doing anything with it
	//  And make sure I use some hokey html attributes to edit it instead of doing some
	//  real editing in my php when I read it in, if I ever figure out how.
	//  And why use a number field to display something called "itemname"??
	echo "
		<td>{$rowww['itemName']}</td>
		<td>
		<form action=''>
		<input type='number' id='quantity' name='quantity' min='1' max='50' style='width:3em;'>
		</form>
		</td>
		";
		// The end of my display of ONE item all by itself that no web browser is ever going to display
}

Sorry for being so harsh but you made absolutely no sense.  Are you asking for help with a problem or showing us how you would do it?  Really hard to tell from the way you posted this.  Barand told you as much.  I just went a lot further.  Call me irritable.

Edited by ginerjm
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.