Jump to content

Need to insert form in php output


ghosttr

Recommended Posts

I have this code displays my database information in a table. I have a 2 column table the first column is for the data, the second is where i want the script to put the form.

 

<?php
$username="<username>";
$password="<password>";
$database="<database>";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "SELECT name FROM <table1>";

$result = mysql_query($query) or die(mysql_error());
echo "<table border='1'>";
echo "<tr><th>Name</th><th>Value</th></tr>";
while($row = mysql_fetch_array($result)){
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
}


echo "</table>";
//}

?> 

 

Since the number of items will vary from time to time its not very practical to create static forms either

Link to comment
Share on other sites

I have a list of items that when imported to my database have no value. I need to give each item a value, which i have been doing manually through phpmyadmin. I have been using a script that moves the unedited items to a different table that i merge with the real list when im done editing it.

 

The problem is that this is very time consuming. So i have this script which is pulling the list of unedited items, and displaying them in a form. And what needs done is that for every item it lists the script also needs to generate a form with it, so that i can just enter my data, and submit it when im all done.

 

Im still new to php and haven't been able to find a way to do this. I need something like this

for every <item> insert <form>

that will generate a form for every item

Link to comment
Share on other sites

if this is a "throw away" script, why don't you d/l the files from the table, create a text file the way you want it, then upload it and be done.  beats what you are doing...

 

 

 

 

Well that works too, but i would also like to be able to let other who dont have database access edit the list if i need them to. If I could add a form to the results it would mean  that i could provide a link to the page and have someone else edit it. And I could remove the second table and just use a select command to get the data, edit it through the forms and repost it back into the original database.

Link to comment
Share on other sites

short of writing the script for you, just display the table to screen and just add the second field with what is in it set as the value of the input box, and let them either edit the field or leave it as is, when they are done making changes the submit writes all the changes...

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.