New to this, but I have the below problem:
Right now I have a working script, but if there is no $merchant result, I still want to display the form that sits below:
I've tried including "IS NULL" for this, but looking at similar examples I'm not sure if this is the right move?
Here is my working current code, any recommendation welcome:
<?php
if (is_user_logged_in()):
$merchant = wp_get_current_user()->display_name;
global $wpdb;
$customers = $wpdb->get_results("SELECT * FROM profile WHERE merchant = '$merchant';");
echo "<form>";
foreach($customers as $customer){
echo "<h2 class='columnTitle'>".$customer->merchant."</h2>";
echo "<label><b>Display name:</b><br></label>";
echo "<span>".$customer->displayname."</span><br><br>";
echo "<label><b>About you:</b><br></label>";
echo "<span>".$customer->about."</span><br><br>";
echo "<label><b>Address:</b><br></label>";
echo "<span>".$customer->street."</span><br>";
echo "<span>".$customer->area."</span><br>";
echo "<span>".$customer->postal_code."</span><br>";
echo "<span>".$customer->city."</span><br><br>";
echo "<label><b>Website:</b><br></label>";
echo "<span>".$customer->website."</span><br><br>";
};
echo "</form>";
else:
echo "Sorry, only registered users can view this information";
endif;
?>
question from:
https://stackoverflow.com/questions/65872189/including-null-results-with-get-results 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…