newtoall Posted April 7, 2007 Share Posted April 7, 2007 I have a mysql table called 'table1' will columns 'col1', 'col2', 'col3'. I have written a php script so I can update the table from a web browser. However I have no idea how to retrieve the information back into a web form so I can update it then save it. Can anyone tell me how to do this please, or point me in the direction of some example code. I know this is probably basic stuff, but I am just learning as I go, so please be kind....... ??? ??? ??? ??? Link to comment https://forums.phpfreaks.com/topic/46003-stupid-question-from-php-newbie/ Share on other sites More sharing options...
PC Nerd Posted April 7, 2007 Share Posted April 7, 2007 ok, this is really rough, but you can look up the functions i use so that their relevent to your version of mysql etc. $sql = "SELECT col1, col2, col3 FROM table1 WHERE coll1 = '".$Value_to_test."'"; $query = mysqli_query($Connection, $sql) or die("could not run query"); $result = mysqli_fetch_array($query); ### do stuf with data. read up on the mysql_***** functions. i wont run through a full tutorial here, but google it. if you know a but about php, or even programming in general, then it should be reasonably easy to understand. good luck Link to comment https://forums.phpfreaks.com/topic/46003-stupid-question-from-php-newbie/#findComment-223535 Share on other sites More sharing options...
newtoall Posted April 7, 2007 Author Share Posted April 7, 2007 Cheers for the quick reply, I can get the data back out of the database and display it in the browser OK, but I am not sure how to pre-populate a HTML form with the data once I have it. Link to comment https://forums.phpfreaks.com/topic/46003-stupid-question-from-php-newbie/#findComment-223540 Share on other sites More sharing options...
AndyB Posted April 7, 2007 Share Posted April 7, 2007 Retrieve the data and display it in the form in the fashion below: <input type="text" name="col1" value="<?php echo $row['col1'];?>"/> <textarea name="long_stuff" rows="10" cols="30"><?php echo $row['long_stuff'];?></textarea> Adjust to suit your own data and how those data are abstracted from each row ... Link to comment https://forums.phpfreaks.com/topic/46003-stupid-question-from-php-newbie/#findComment-223545 Share on other sites More sharing options...
newtoall Posted April 7, 2007 Author Share Posted April 7, 2007 Thanks, This works a treat!! Link to comment https://forums.phpfreaks.com/topic/46003-stupid-question-from-php-newbie/#findComment-223586 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 please click solved Link to comment https://forums.phpfreaks.com/topic/46003-stupid-question-from-php-newbie/#findComment-223593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.