How do you put php within php? The script below is where I am trying to place the php within the php script. Near the bottom for the function boutique_product_name. That line of code has two separate instances of calling functions but it must nest within this mysql table. I’ve omitted alot of the code that was not necessary to display so it would be easier to follow. But it will eventually be a mysql table pulled from an xml file for magic the gathering cards. Which will include pricing data and the ability to buy the cards hence which is what the functions at the bottom are for.
I will still need to figure out how to make actual product pages for each card within the table but that’s for later.
So if anyone knows how in the world to place a
<?php
$z = new xmlreader;
$z->open('http://*****.com/wp-content/themes/*****/mtg/arb.xml'); // Your XML File name
$doc = new DOMDocument;
while ($z->read() && $z->name !== 'card');
echo "<table border=1>
<tr></tr>";
while ($z->name === 'card')
{
$node = new SimpleXMLElement($z->readOuterXML());
echo "<tr>
<td><div class='id1'>".$node->id."</div></td>
<td><div class='cardname1'>".$node->name."</div></td>
<td><div class='set1'>".$node->set."</div></td>
<td><div class='cardtype1'>".$node->type."</div></td>
<td><div class='rarity1'>".$node->rarity."</div></td>
<td><div class='manacost1'>".$node->manacost."</div></td>
$id = $node->id;
$name = $node->name;
$set = $node->set;
$type = $node->type;
$rarity = $node->rarity;
$manacost = $node->manacost;
$sql = "INSERT INTO `*****_wrdp2`.`cards`
(`id`, `name`, `set`, `type`, `rarity`, `mana cost`)
VALUES
('$id', '$name', '$set', '$type', '$rarity', '$manacost');";
if(mysql_query($sql))
{
echo "<td><div class='error'><font color='green'><b>Success!</b></font></div></td></tr>";
} else {
echo "<td><div class='error'><font color='red'><b>Failure! (".mysql_error().")</b></font></div></td></tr>";
}
echo "<a href="#<?php echo boutique_product_name('offer'); ?>" class="add-to-cart et-shop-item"><?php esc_html_e('Add to cart','Boutique'); ?></a>";
$z->next('card');
}
echo "</table>";
?>
Technically, you are looking for “eval”, but I don’t think that is really what you want. You seem to be passing in the same argument to the function every time. If this is done well, then the same input should result in the same output.
Can’t you just call: