[Solved] Can I store query result of one field into different variables? if not then what should I do for that?

$query = mysql_query(“select `subject` from `markssub1` where `sname`=’$user’ AND `sid`=’$id'”); $subjects = []; while($row = mysql_fetch_array($query)) { $subjects[] = $row[‘subject’]; } foreach($subjects as $subject){ echo $subject . ‘\n’; } 3 solved Can I store query result of one field into different variables? if not then what should I do for that?

[Solved] SQL Print the name of all Employees together with the name of their supervisor

An inner join should do it. Here’s the syntax, but you’ll have to apply it to your database: SELECT c.name, o.name FROM cats c INNER JOIN owners o ON c.owner_id = o.id “cats c” basically means “Cats table, which I’m nicknaming c.” “owners o” basically means “Owners table, which I’m nicknaming o.” In your select, … Read more

[Solved] How to SUM Datetime per column

AS some of your logstep_* columns value is NULL so try like this with ifnull, I’ve added only three columns you can try with all of your columns. Hope this will help you. select SEC_TO_TIME( UNIX_TIMESTAMP(ifnull(logstep_1, 0)) + UNIX_TIMESTAMP(ifnull(logstep_2, 0)) + UNIX_TIMESTAMP(ifnull(logstep_3, 0)) ) as logstep_sum_in_time from log_step 2 solved How to SUM Datetime per … Read more

[Solved] How big can CMS database be? [closed]

I know this has tons of downvotes, but you can cache your database queries. You can also mimic a CSS file using the header type in PHP. See http://css-tricks.com/css-variables-with-php/ This will allow the browser to cache the CSS file that was generated by PHP & MySQL. This means the database will only be called when … Read more

[Solved] Gather column name of a table from database [closed]

http://php.net/manual/en/function.mysql-num-fields.php $result = mysql_query(“select * from table”); echo ‘<tr>’; for ($i = 0; $i < mysql_num_fields($result); $i++) { echo “<th>”.mysql_field_name($result, $i).”</th>”; } echo ‘</tr>’; 1 solved Gather column name of a table from database [closed]

[Solved] Sendmail as HTML output [closed]

Add Content-type:text/html;charset=UTF-8 to you header and remove * from html tags like this $headers = “MIME-Version: 1.0” . “\r\n”; $headers .= “Content-type:text/html;charset=UTF-8” . “\r\n”; $headers .= “From: <****@example.com>’ . “\r\n”; $headers .= “Cc: ****@example.com’ . “\r\n”; $message =” <html> <head> <title>HTML email</title> </head> <body> <div>Hello ” . $row[‘first_name’] . ” ” . $row[‘last_name’] . “</div> … Read more

[Solved] PHP and Mysql Permission system [closed]

Try to use this: if ($accounttype == ‘a’) { print ‘Member’; } elseif ($accounttype == ‘b’) { print ‘Moderator’; } elseif ($accounttype == ‘c’) { print ‘Admin’; } else { print ‘No rank’; } You need use strings in a quotes, and don’t forget semicolons ; at the end of line 3 solved PHP and … Read more

[Solved] SQL query to retrive data [closed]

Better version in a single query: select p1.productname from Product p1, myorder s1, lineitem l1, customer c1 where l1.pid=p1.pid and l1.OID=s1.oid and c1.cid=s1.cid and c1.city=’mycity’ group by p1.ProductName having count(distinct c1.cid)=(select count(1) from customer c2 where c2.city=’mycity’); solved SQL query to retrive data [closed]

[Solved] Data Base Query [closed]

If I understood your question properly, then query should be like this SELECT state_name,district_name from TableName WHERE id=’jk-01′ //you can have your specific id here 1 solved Data Base Query [closed]

[Solved] How to join multiple tables mysql

This most likely won’t work since I have very little information to go on but you’re probably looking for a query somewhat like this: SELECT `order`.orderID, menuItem.`item-name`, menuGroup.`grp-name` FROM menuItem JOIN menuGroup ON menuGroup.menuGrpNo = menuItem.menuGroup LEFT JOIN orderItems ON orterItems.menuItemNo = menuItem.menuItemNo LEFT JOIN `order` ON `order`.orderID = orterItems.orderID AND `order`.orderDate BETWEEN ‘2012-02-01’ AND … Read more