Jump to content

Recommended Posts

I have this code:

 

$data = array_combine($data4, $addfinal);

foreach( $data as $key => $value){
?>

<tr>
<td><?php echo $key;?></td><td><?php echo $value; ?></td><td></td><td>Safeco</td><td><a href="ajax/map.php?address=<?php echo urlencode($value);?>">Map It</a></td>
</tr>
<?php
}

That uses an array that looks like this (but longer):

Array ( [business Name 1] =>
Business Address 1 [business Name 2] =>
Business Address 2 [business Name 3] =>
Business Address 3)

But it skips every other array entry? Any ideas? So its displaying Business Name 1, Business Name 3, etc.

Does the 'view source' of the page have all the data?

 

I suspect that your key or value contains html that is breaking the html of the table.

 

To test that theory, what does this give you?

foreach($data as $key => $value) {
echo 'Key: ' . htmlspecialchars($key) . ' Value: ' . htmlspecialchars($value) . '<br />';
}

Thats where its a bit complicated. I cant view source, I am using jQuery ajax with a jQuery paginator/search table. I am stripping tags on the table rows as they display I just omitted for ease of read.

 

Use dev tools like firebug, chrome dev tools, or fiddler2 to view the ajax transaction that takes place and inspect the data being returned by your script to see if it is missing the rows or if the data is just malformed somehow.

 

damn, thats wierd, the ajax is returning all the data correctly. Now what?

Sounds like now it's time to start debugging your JS code to see what it is doing.  If it comes back from PHP ok then something in your JS must be causing it to skip rows.  If your using a pre-packaged script to do things read the docs and make sure it is setup properly.  If it's your own code start tossing in some console.log statements to find out what it is doing.

 

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.