Current location: Hot Scripts Forums » Programming Languages » PHP » How to read data from <table> with php


How to read data from <table> with php

Reply
  #1 (permalink)  
Old 12-21-08, 09:25 AM
sidd sidd is offline
Newbie Coder
 
Join Date: Dec 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Question How to read data from <table> with php

Hello Everybody,

I am new with PHP and trying to explore the things with php. here is my problem please

I have a table

<table>
<tr>
<td> name</td>
<td>address </td>
</tr>
<table>

this is the basic structure of my table i put other values in it with help of javasciprt from a other table. I have one more table and user can select from there some name and addresses...on double click of other table i populate this basic table...

Now I want to put these selected name and address in this basich table in database but how i can read these items with php

Please any body can help me for this regards.

wating for a quick reply.

Thanks

Best Regards,

Sidd
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-21-08, 05:14 PM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
use javascript to dump the values into a form field textarea so you can retrieve them through php with the $_POST array

I would probably just go straight down the

PHP Code:


$SteriliseTable 
$_POST['thatfieldnane'];

$SteriliseTable str_replace("<table>""",$SteriliseTable); 
$SteriliseTable str_replace("<tr>""",$SteriliseTable); 
$SteriliseTable str_replace("<td>""",$SteriliseTable); 
$SteriliseTable str_replace("</td>"",",$SteriliseTable); 
$SteriliseTable str_replace("</tr>""",$SteriliseTable); 
$SteriliseTable str_replace("</table>""",$SteriliseTable); 
you may need to use regular expression if the table structure has more complications such as javascript or css classing and styling options but if it stays as simple as this then the above code will produce a CSV that can be passed for recording in the db

I havnt tested this code but I'm sure you wont have issues with it, double check any errors as I tend to forget things like the conformity of keyword names.

Cheers
Dal
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 12-22-08, 07:12 AM
sidd sidd is offline
Newbie Coder
 
Join Date: Dec 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Question

Hi Dal,

If you can guide me please what do you mean with 'thatfieldnane' because table have no 'name' only 'id' how i can read that with $_POST

HTML Code:
<table class="font_all   " id="Items"  >
<tr>
	<th>Name</th>
	<th>Address</th>
	<th >X</th>
</tr>

</table>

<br />
<div>
<input type="submit"  class="input_all" /></div>
				
please have a look i have this basic table and put there values with javasciprt from other table when user double click on other table..Now on click of this submit button i have to send values to database that are avaliable on above table.

wating for your kind reply.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 12-22-08, 07:19 AM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
Well it's a little hard to explain if your not seeing the solution I explained. In that case I would suggest using what you already have with javascript creating the table for you them values are already floating around somewhere. Have you got the script handy that passes the data to this new page as I could advise you easier on that rather than go into too much detail here regarding my previous solution.

Kind regards
Dal
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 12-22-08, 07:31 AM
sidd sidd is offline
Newbie Coder
 
Join Date: Dec 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Question

Hi Dal,

Be frankly i dont have an idea in which I can do that. doing some other nice things with php but here i am little bit confused in which way it will work..?

Thanks.

Regards,
Sidd
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 12-22-08, 07:38 AM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Sidd,

Without code I can't see how it would work, my suggestion was kind of based on the assumption that you were able to understand that the name of a textbox or textarea was passed to php and that since you already have created a javascript to prepare the data in this fashion, that my theory would have been easy to implement.

Since this was an issue I can't very well advise you without first seeing the way the current script works, is it theory your after or is it advice on where to go with the script?

Kind regards
Dal
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 12-22-08, 07:49 AM
sidd sidd is offline
Newbie Coder
 
Join Date: Dec 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Dal,

Okay let me try. Let me try to explain you i have two table A and B from table A user can double click and select the thing these selected things I put in table B that is above mentioned. Now from table B what items user have selected i want to put them in database on click of this submit button.

But I dont know how i can read these values form table B with POST or GET weil I think I only can read values with POST and GET from those element those have a 'name' property but table have an 'id'

If you got me.?

Best Regards,
Sidd
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 12-22-08, 08:03 AM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
Ok if we are just going through this in theory then I would suggest reading up further on php before asking questions about it. With all respect I provided you a theory it's up to you to either use my advice or not. I'm sure others will come up with other suggestions on how to solve this but when I looked at your post I read it in the way that you required help with the idea on how to pull data from a html table source and I provided just that. If I cant see the code then I cant suggest anything particular as it would be a stab in the dark. FYI you CANT $_POST a table, you can only $_POST a form field like a text box or TextArea which is what I suggested.

Kind regards
Dal
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 12-22-08, 08:11 AM
sidd sidd is offline
Newbie Coder
 
Join Date: Dec 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Dal,

I am agree with your suggestion..just trying as you suggest me I think it will work.

Best Regards,
Sidd
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 12-22-08, 09:17 AM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
Well post your code if you have any issues with the php side of things but your going to need to use javascript to pop the innerHTML into the form feild I imagine.


Remember to mark your thread solved once your cool with it.

Kind regards and good luck
Dal
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP or PHP which is better? nepala The Lounge 9 07-14-10 06:48 AM
Update of data using PHP truncates text data jej1216 PHP 8 09-10-08 09:52 AM
How to read the last row of Db in SQl +PHP csv PHP 3 03-11-08 07:09 AM
question about processing data of php ? Mythvn PHP 4 02-24-08 06:03 AM
How to get PHP to input data into a MYSQL table? scl789 PHP 5 04-21-05 10:06 PM


All times are GMT -5. The time now is 12:51 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.