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

Link to comment
Share on other sites

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