Any help in the right direction, is greatly appreciated, Thank you in advance.
Here's my code to fetch data from MYSQL Database using PHP ---------------
$.getJSON("BeckysCars_load_automobile_data.php", function(data) {
$.each(data, function(index, data) {
//$("#automobile_body_content").append('');
$("#automobile_body_content").append('
');
//$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
//$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
//$("#automobile_body_content").append('
');
});
});
------- This is my layout where my data will be displayed in the tbody section -----------
Automobile Businesses
Company | Email | Phone# | Fax# | Address | City | State | Zipcode | Country | Hiring | Coupons |
-------- When button is clicked in that row, i want to view the data for that row ------------
$(".coupon_button").on('click',function(){
var arrData = [ ];
// loop over each table row (tr)
$("#myAutoTable").each(function(){
var currentRow = $(this);
var col0_value = currentRow.find("td:eq(0)").text();
var col1_value = currentRow.find("td:eq(1)").text();
var col2_value = currentRow.find("td:eq(2)").text();
var col3_value = currentRow.find("td:eq(3)").text();
var col4_value = currentRow.find("td:eq(4)").text();
var obj = { };
obj.col0 = col0_value;
obj.col1 = col1_value;
obj.col2 = col2_value;
obj.col3 = col3_value;
obj.col4 = col4_value;
arrData.push(obj);
});
alert(arrData)
console.log(arrData);
});
----- if i put the "tr" in the #MyAutoTable selector i get this output -------------------
alert output:
[object Object][object Object][object Object][object Object][object Object]
console.log output:
0: {col0: "", col1: "", col2: "", col3: "", col4: ""}
1: {col0: "", col1: "", col2: "", col3: "", col4: ""}
2: {col0: "", col1: "", col2: "", col3: "", col4: ""}
3: {col0: "", col1: "", col2: "", col3: "", col4: ""}
4: {col0: "", col1: "", col2: "", col3: "", col4: ""}
5: {col0: "", col1: "", col2: "", col3: "", col4: ""}
length: 6
----- But if i remove the "tr" from the #MyAutoTable selector i get this output, but every button press gives me the same data ------------------
alert output:
[object Object]
console.log output:
col0: "Becky's Cars"
col1: "me@gmail.com"
col2: "678-789-9000"
col3: "678-789-9001"
col4: "34 West 29th street"
__proto__: Object
length: 1