[Solved] Single result from database using mysqli

When just a single result is needed, then no loop should be used. Just fetch the row right away. In case you need to fetch the entire row into associative array: $row = $result->fetch_assoc(); in case you need just a single value $row = $result->fetch_row(); $value = $row[0] ?? false; The last example will return … Read more

[Solved] Creating HTML table with php output

Your issues lies in your formatting and confusion between the use of the echo command and non PHP wrapped HTML. Code should read as follows when properly formatted. <?php $db_host = “localhost”; $db_username = “vistor”; $db_pass = “visitor”; $db_name = “test”; $db = new PDO(‘mysql:host=”.$db_host.”;dbname=”.$db_name,$db_username,$db_pass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $query = $db->query(“SELECT * FROM pet’); ?> <html> … Read more

[Solved] Complicated regex in PHP

try this: <?php $q1 = “{Hello|Hi} sir.”; $q2 = “{How are you?|How are you doing?}”; $q = substr($q1, 1, strpos($q1,’}’)-1); $q_end = substr($q1, strpos($q1, ‘}’)+2); $parts = explode(‘|’,$q); echo “<select name=\”q1\”>\n”; foreach($parts as $part){ echo “\t<option value=\””.strtolower($part).”\”>$part</option>\n”; } echo “</select>\n”; echo $q_end . “\n”; $q = substr($q2, 1, strpos($q2, ‘}’)-1); $parts = explode(‘|’,$q); echo “<select … Read more

[Solved] Browser detection in PHP causes white screen [closed]

This is my first comment here sorry if its not perfect. I think its because you’re trying to echo everything at once. <?php if (strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Firefox’) !== FALSE || strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Chrome’) !== FALSE || strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Opera’) !== FALSE || strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Safari’) !== FALSE) { $str=”<script>$(document).click(function() {“; $str .= ‘ window.open(“http://google.com”, “_blank”);’; $str .= ‘ });’; … Read more

[Solved] If in Array on PHP [closed]

I’m guessing you’re trying to find out if $catId is in the $result_2 array. If so, then you’ve already answered your question with your title here.. in_array if(in_array($catId,$result_2)) solved If in Array on PHP [closed]

[Solved] php add counter with thousands separator [closed]

Preety straight forward answer for you… <?php $fp = fopen(“counters/counterlog.txt”, “r”); $count = fread($fp, 1024); fclose($fp); $count = $count + 1; echo “<p>Pageview: ” . number_format($count) . “</p>”; // <=== $fp = fopen(“counters/counterlog.txt”, “w”); fwrite($fp, $count); fclose($fp); ?> 1 solved php add counter with thousands separator [closed]

[Solved] mysql Search data from multiple table

Introduction MySQL is a powerful and popular database management system used by many businesses and organizations. It is capable of storing and retrieving data from multiple tables, allowing for complex queries and data manipulation. In this tutorial, we will discuss how to search data from multiple tables in MySQL. We will cover topics such as … Read more

[Solved] how to add checkbox in select option in php?

I’m not sure I understand the principle of putting a checkbox in a list. If this is to select all default item, you may use the lists multipe with the selected option on the option tags <select multiple size=”10″> … <option selected=”selected” value=”<?=$row[‘first_name’]?>”><?=$row[‘last_name’]?></option> …. good luck 🙂 solved how to add checkbox in select option … Read more