I have made a web page which is a grouping of three HTML tables that reads or writes different parts of an order (customer information, parts information, and price totals). I am trying to have the page pull data from a MySQL table so specific users can edit it. I am having trouble with this. I have tried to attach the code but no luck.
Is there anyway someone could please look at my code and point me in the right direction? Its a lot of code to post here but I am willing to get it on here if needed...
Thanks, Erik!
Best way to make table data editable?
Moderator: General Moderators
Re: Best way to make table data editable?
I'm afraid you haven't given us much to work with. If you copy/paste your code here and give us specific examples of what isn't working, we'll be better able to help.
Re: Best way to make table data editable?
Sorry about that, I do realize that. The code is quite lengthy that's why I didn't post it, and it wouldn't allow me to upload it. I guess if I were to put into simpler terms, is there a base example of how I can have data show up in an html table?
I have copied over the PHP script i am using to pull the data from the mysql table. I have edited out some for length purposes...
<?php
$submittedby = $_GET["submittedby"];
$submittedtime = $_GET["submittedtime"];
$projectname = $_GET["projectname"];
...etc
// Connect to sqlbd port 3307
mysql_connect ('sqldb',user','pass') or die ('Error Connecting To Database Server, Please contact IT!');
mysql_select_db ('db_name');
// START THE QUERY
$query="UPDATE orderstest SET
(submittedby='$_GET[submittedby]',submittedtime='$_GET[submittedtime]',projectname='$_GET[projectname]'... etc)";
// RUN THE QUERY OR DISPLAY AN ERROR
mysql_query($query) or die ('Error Updating Orders Test Database || Return to <a href="mockup.php">Order Form</a>');
?>
I have copied over the PHP script i am using to pull the data from the mysql table. I have edited out some for length purposes...
<?php
$submittedby = $_GET["submittedby"];
$submittedtime = $_GET["submittedtime"];
$projectname = $_GET["projectname"];
...etc
// Connect to sqlbd port 3307
mysql_connect ('sqldb',user','pass') or die ('Error Connecting To Database Server, Please contact IT!');
mysql_select_db ('db_name');
// START THE QUERY
$query="UPDATE orderstest SET
(submittedby='$_GET[submittedby]',submittedtime='$_GET[submittedtime]',projectname='$_GET[projectname]'... etc)";
// RUN THE QUERY OR DISPLAY AN ERROR
mysql_query($query) or die ('Error Updating Orders Test Database || Return to <a href="mockup.php">Order Form</a>');
?>
Re: Best way to make table data editable?
You mean something like this?ehauser wrote:I guess if I were to put into simpler terms, is there a base example of how I can have data show up in an html table?
Code: Select all
<?php
$sql = new mysqli(connection parameters here);
$query = "SELECT foo, bar, baz FROM table WHERE whatever";
$result = $sql->query($query);
?>
<form>
<table>
<?php while ($row = $result->fetch_object()) { ?>
<tr><td><input type="text" name="foo" value="<?php echo $row->foo; ?>" /></td></tr>
<tr><td><input type="text" name="bar" value="<?php echo $row->bar; ?>" /></td></tr>
<tr><td><input type="text" name="baz" value="<?php echo $row->baz; ?>" /></td></tr>
<?php } ?>
<tr><td><input type="submit" value="Submit" /></td></tr>
</table>
</form>Re: Best way to make table data editable?
Yes, that is basically what I was looking for. As you can see, the code I had found and edited wasn't working correctly and I knew that was a simpler way to do it. I'll start out with what you had an edit it into what I am doing.
Thanks so much!
Thanks so much!