You are here:  » how to do this


how to do this

Submitted by xsabn on Sun, 2007-11-11 01:19 in

Hello!
I am new with magic parser. seems to look great but must get used.
How i convert this table to magic parser format?
Thanks in advance!

 <?php
require_once('rss/mysponsorRSSParser.php');
?>
 <?php
$online_feed_url = 'http://sponsor.com/rss/';
$online_models = sponsorRSS::parse_online_models($online_feed_url);
$num_columns = 5;
?>
    <table width="100%" align="center" border="1" style="border-width:0px;" cellpadding="4">
      <?php $column 0?>
      <?php foreach($online_models as $online_model): ?>
      <?php $column++; ?>
      <?php if($column == 1): ?>
      <tr>
        <?php endif; ?>
        <td align="center" style="border-style: none; border-width: medium"><a style="font-size: 10px; color: #0000FF;" target="_blank" href="<?php echo $online_model->link ?>"><img src="<?php echo $online_model->image_url ?>" width="90" height="60" alt=" <?php echo $online_model->screen_name ?>"><br />
          <?php echo $online_model->screen_name ?></a><br />
          <a href="../cat/profil.php?model_name=<?php echo $online_model->model_id ?>">See my profile</a><br />
          <a style="font-weight:bold; color:#00CC00;" href="http://sponsor.com/afflink/">Join now!</a></td>
        <?php if($column == $num_columns): ?>
        <?php $column 0?>
      </tr>
      <?php endif; ?>
      <?php endforeach; ?>
      <?php if($column 0): ?>
      <?php while($column $num_columns): ?>
      <?php $column++; ?>
      <td style="border-style: none; border-width: medium;">&nbsp;</td>
        <?php endwhile; ?>
      </tr>
      <?php endif; ?>
    </table>

Submitted by support on Sun, 2007-11-11 16:01

Hi,

Without seeing your actual feed it is difficult to give any actual code, but the basic structure will be something like this, creating one column for Model ID:

<?php
  
require("MagicParser.php");
  
// start the table:
  
print "<table>";
  print 
"<tr>";
  print 
"<th>Model ID</th>";
  print 
"</tr>";
  function 
myRecordHandler($record)
  {
    print 
"<tr>";
    print 
"<td>".$record["MODEL_ID"]."</td>";
    print 
"</tr>";
  }
  
// parse the file to create the rows
  
$url "http://sponsor.com/rss/";
  
MagicParser_parse($url,"myRecordHandler");
  
// end the table
  
print "</table>";
?>

If nothing shows up, it is probably because MODEL_ID is wrong. The thing to do is to upload your feed to the Magic Parser demo tool and look at the field names in the table - use exactly the same in your code.

Hope this helps!
Cheers,
David.