Jump to content

Stupid question from php newbie


newtoall

Recommended Posts

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

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

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 ...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.