I currently have a MySQL database that I am accessing using PHP. You search a name and it returns the person's contact information. However, sometimes you search a name that already exists and it returns 2 peoples contact information.
I am inserting the information into an HTML table using JavaScript. PHP is returning the contact information as a long string separated by spaces. And I am using the split function while using the space character as a delimiter.
This is all fine and dandy when the search result only returns 1 name. When it returns 2 names I am having trouble figuring out how separate the two contact's information. Since PHP is returning them as 1 continuous string.
Here is an snippet of my php code:
$data = mysql_query($sqlString) or die("Issue here:" . mysql_error());
while($row = mysql_fetch_array($data)){
print $row['firstName'] . " " . $row['lastName'];
};
Here is a snippet of my JavaScript Code:
$.post("searchDB.php", {search:$("#searchValue").val(),
searchType:$("#searchType").val()},
function(results) {
var parsedResults = results.split(" ");
//code for inserting into HTML.
});
$sqlString
might be illuminating - without that information, it is hard to see how you are running into problems.