MySQL results to html forms using PHP
Hi,
I have a problem I have a database filled with books, their ISBN's publishers and titles, and so forth I use this code to browse the books on my website, Code:
$query = "select * from books"; The solution I've come up with (if theres a better and easier way please tell me) is to somehow dynamically take this info and load it into a form (into the <input tages>, and lock all the form attribuates and add a quantity attribute the user can edit, and then post this info over to the checkout.php script But the problem is I have no idea how to take this information from the databae and load it into a form, and how to somehow get php to dynamically create <input tags> one after the other as they are needed for how ever many books are searched or browsed in the database So if anyone knows where to look next, (two books on php and sql and a html book plus php.net and a google I cant find anyone with a similar probem) please post some urls or code examples Cheers ! |
Just posting a update to my problem, i manage to get the <input tags> working
I just Code:
echo "<br><b>Quantity:</b><input name=\"quantity\" size=\"3\" value=\"0\">"; Sorry for any confusion, if you guys know a better way to do this It would be great if you can post it. Cheers. |
I have found a solution, I'll try using a some javascript to add up the costs of each item, I hope the Jscript will work while its imbedded in a php tags? If not I'm back to square one.
//update Yes, Jscript is embeddable in php tags |
Use PHP all the way through. You can setup a session array with the variable stuff in it and fill your input fields from it. I'd show you my website that does something similar, but it's company-private and password only access.
BTW, in your input tags echo()s use single quotes for the echo()ed string, then you don't have to escape all the inner double-quotes. You'll have to do some fancy quoting if you're trying to embed variables, of course! |
All times are GMT -5. The time now is 12:02 AM. |