[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

MySQL Server

47K

Solutions

23K

Contributors

MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi,

Looking for advice on how best to change the background colour of a cell's table row based upon it's contents.

This is the basic code: -

<div><h5>Process Check - Total No. of Units which Failed to Transfer (Last Addition)</h5></div>
	<table id="table" class="table table-bordered table-striped table-hover">  
				<thead>
					<tr>
						<th class="success text-left">Date of Deduction</th>
						<th class="success text-left">Total No. of Units</th>
					</tr>
				</thead>
				<tbody class="searchable">

	<?php
	
	$query = "select timestamp, totalAssemblyUnits from sumAssemblyUnitsGoodsIn2 order by timestamp desc limit 1";

	if (!$result = $mysqli->query($query)) {
		$err
		= "QUERY FAIL: "
		. $query
		. ' ERRNO: '
		. $mysqli->errno
		. ' ERROR: '
		. $mysqli->error
		;
		trigger_error($err, E_USER_ERROR);
		}

		while ($row = $result->fetch_object()) {
		$tr = <<<EOD
				<tr>
					<td> $row->timestamp </td>
					<td> $row->totalAssemblyUnits </td>
				</tr> 
EOD;
		echo $tr;}

	?>
	</table>

Open in new window


If the mySql Output for "<td> $row->totalAssemblyUnits </td>" is ever less than zero, then I like to colour the background of the cell red, otherwise it should be coloured green.

Hope that makes sense?

J
0
I am trying to check my entire cart array against the database when a user checkouts to make sure that they items in their cart are still actually available and another user didn't purchase the last of an item somewhere in between. But I am having a hard time trying to figure out getting more than one record. Before I even get to checking what is in the cart vs the database, I am just trying to get the quantities in the database for each product id at this stage.

Here is my controller that is just putting the data from the database call into the $totals variable.

	public function checkoutDbQtyCheck()
	{
		if(isset($_SESSION['cart_array'])) {
			
			$response = array();
			
			$totals = $this->ProductFendModel->finalDbQtyCheckoutCheck();
			
			$response['cart'] = $totals;
			echo json_encode($response);
		
		}
	}

Open in new window


This is the database query in the model:

	public function finalDbQtyCheckoutCheck()
	{
		$purchased = '0000-00-00';
		$this->db->query("SELECT COUNT(`product_id`) as `vouchersLeft`, `product_id` FROM `vouchers` WHERE `product_id` = :product_id AND `purchased` = :purchased");
		$this->db->bind(":purchased", $purchased);
		$this->db->bind(":product_id", $prod_id);
		
		foreach($_SESSION['cart_array'] as $cart) {
			$prod_id = $cart['prod_id'];
			$quantity = $cart['quantity'];
		}
		
		$results = $this->db->resultSet();
		return $results;
	
	}

Open in new window


Whether I put $results in the foreach loop or where it is now, I only get back one result even though there are multiple items in the cart.
0
Hi Experts

Could you point a way to code a multichoices combo by using "Smarty" PHP library?

Thanks in advance!
0
This is a follow on to this question - https://www.experts-exchange.com/questions/29107724/Need-Category-Sorted-By-Product-Not-First-Letter.html#acceptAnswerByMember

Need to have category page sorted by product and within by description.  Putting $off, %off, buy x.  With the x amount being in an ascending sequence.

For example, Buy 4 then Buy 5 then Buy 9 etc.
0
Hi Experts

Could you point a strategy to call a new CRUD view to complete an existent register?

Accordingly with:

img002
The basic data is still registered,

My first attempt is to put a button to call a view and then enter the Address informations (and then communications info maybe by another button)

Is it a good strategy?  or possibly you could suggest anything else.

I'm using pure PHP in a custom MVC project (no PHP frameworks used).

Thanks in advance!
0
How to write php output to excel? more than 100 rows and each 10 column. Platform linux.
0
MySql download

I am planing to downoad Mysql, however I see there are separate files to download. Mysql Installer,Connector,Workbench,Notifier.etc...
My objectif is to download Mysql and be able to connect  to it through its own GUI, also be able to  use a program language to connect to it programatically

any help ?

Thank you
0
I have a MySQL database. When I fetch a specific record with "SELECT * from projects where pid = 40", I get the attached. Note the column bfh1 = "Y". I have a php program that reads the contents of the record & stores the results into a series of $_SESSION variables. That program, with echos added to see what is happening, is here:
<?php
error_reporting(E_ALL);
// load_proj.php
$pid = intval($_GET['ppid']);
$nosumm = intval($_GET['nosumm']);
$ddocs = $_GET['disp_docs'];
//echo "ddocs in load_projn = " . $ddocs . "<br>";
session_start();
include "db_connect_nb.php";
$qry = "SELECT * from projects where pid = " . $pid;
echo "proj qry= " . $qry. "<br>";
$res = mysqli_query($link, $qry);
$p = mysqli_fetch_array($res,MYSQLI_ASSOC);
echo "p[bfh1] = " . $p['bfh1'] . "<br>";
// set all the session stuff
$_SESSION['project'] = $pid . "~" . $p['project_name']; 
$_SESSION['cltype'] = $p['cltype'];
$_SESSION['class'] = $p['cltype'];
$_SESSION['wttp'] = $p['wttp'];
$_SESSION['liq_type'] = $p['liq_type'];
$_SESSION['liq_source'] = $p['liq_source'];
$_SESSION['pgrp'] = $p['pgrp'];
$_SESSION['flow'] = $p['flow'];
$_SESSION['flevel'] = $p['flevel'];
$_SESSION['access'] = $p['access'];
$_SESSION['model'] = $p['model'];
$_SESSION['net_price'] = $p['net_price'];
$_SESSION['total_price'] = $p['trade_price'];
$_SESSION['mtype'] = $p['Material'];
$_SESSION['afs'] = $p['AFS'];
$_SESSION['wof'] = $p['wof'];
$_SESSION['atra'] = $p['atra'];
$_SESSION['abf'] = $p['ABF'];
$_SESSION['spapp'] = 

Open in new window

0
Hi,

im curious if there is a way to do the following in PHP but within a stored procedure with SQL on the fly

$managers = array(
	0 => array(
		"id"	=> 1,
		"name"  => "manager",
		"email"	=> "email"
	)
	...
)

foreach($managers AS $d){
	//send mail
	mail(...);
	
	//Insert into messages table
	INSERT INTO...

}

Open in new window


Essentially, i would want to SELECT the manager from a table and then immediately insert it a message into the massage table

for example:

1. select manager 1
2. insert message into message table for manager 1
3. repeat for manager 2
,...so on

I would handle sending the email using php

I KNOW i can do this in a few steps such as
1. Select all the managers and organize them into an array to loop over
2. loop over the managers and create an array of emails as well as sql statements i can create a transaction with and submit the inserts all at once
3. complete loop
4. send the transaction to sql
5. send the email

but i am curious if i can do it one for one within a stored procedure

Thanks in advance
0
can I connect mysql workbench to two normal desktop or laptop computer
0
Dear experts,
I have table named "followers"
I have information about users on that table. User's id, lattitude and longtitude and the date when the information is recorded on my table.
but it repetitives, same userid has more than one row. I need to select the last inserted userid with latitude and longtitude information.

I want to select the last recoreded userid with the lat, lng columns

My columns are:

id ( auto_increment )
userid
lat
lng
date (datetime)

thank you
0
I'm looking for MySQL query that will replace values in a certain column matching certain value
so in this example I'd like to replace only all ABC  values under only Column1 with say 123 and leave XYZ unchanged, CBD
ID | Column1| Column2
1 | ABC           | blah
2 | ABC           | blah
3 | XYZ            | blah
4 | CBD          | blah

Thanks!
0
I have a MySQL database table called app_codes. It has 8 rows, 2 cols. It is shown in the attached file.

I have the following php code to access the table:
$qryac = "SELECT * from app_codes order by code";
	$resac = mysqli_query($link, $qryac);
	$na = mysqli_num_rows($resac);

Open in new window


Then I have his HTML/php to populate an HTML select element:
<div class="col-sm-5 col-xs-5" style="padding-top:2px; padding-bottom:2px;"><select name="appl_type">
		<option value=""></option>
		<? for ($i = 0; $i < $na; $i++) { 
			$ac = mysqli_fetch_array($resac,MYSQLI_ASSOC); ?>
		<option value="<? print $ac['descr']; ?>"><? print $ac['descr']; ?></option>
		<? } ?>
		</select></div>

Open in new window

All this works exactly as expected. The select has the descr values from the table.

Now, I need to know the code column connected with the selected description.

How can I do that in php or Javascript?  I can build Javascript arrays of both table columns.

Thanks
Appl_type_table.JPG
0
I am having to convert a MS SQL Project to MySQL.
In MS SQL I have a stored Procedure with a complicated Query that uses a Temporary table multiple times to filter out Sub Query.
The Temporary table is filled at the Beginning of the Procedure with a variety of values based on Supplied Parameters.

The Question is how can I do this in MySQL which refuses to allow using a Temporary table twice in the same Query!

The Temporary table simply holds integers with are then used to filter in the pattern of
select * from table A where A.Field in (select Val from TempTable)
Inner Join (Select * from Table B where B.Field in (select Val from TempTable)) as SubTable where SubTable.Field = A.Field
0
I need an app based (session independent) counter that gives me the order of the queries that are done to server.
Does PDO (or MySQL) has an internal counter for that? If it does not have how a can I get the order of the queries without writing to db or using the file system.

What I do right now is
1. construct my PDO object  :
$dbpdo = new PDO("mysql:host=$db_host;dbname=$db_name", $db_username, $db_password, array(PDO::ATTR_PERSISTENT => true));
$dbpdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbpdo->setAttribute(PDO::ATTR_TIMEOUT, 30);
$dbpdo->query("SET NAMES utf8");  
      
2. Do the query:
$q = $dbpdo->prepare($sql);
$q-> execute($arr);

I need the order number of the query (app based)

Thank you
0
hi,

I am going to do some functional test when comparing MySQL Cluster and MariaDB, I know MariaDB by some studies, is faster when compression is on. So any kind of test make mariaDB stand ahead of MySQL cluster and any test can be make to show MySQL cluster is faster than MariaDB?

1) I will do simple select statement and failover.
2) will simple select statement with compression is on and during the select statement is running, I try failover back and forward.
any thing else can show difference of 2 ?
0
I have a mysql table

select  * from parquevw  limit 100

Works fine

But I need it to be output to a tab separated values file like:

select  * from parquevw  limit 100  into 'test.txt'

I get this error:

Access denied for user 'adminp'@'%' (using password: YES)

Where will the test.txt file be saved?

What permissions do I need? Where do I set them?

I have a cpanel linux site

Thx
0
need connect different database as such Mysql and Oracle to the sharepoint by web service
but the issue is oracle cannot connect
i need online help
0
How can I create a mysql database with adminer?

I am using solidcp as conrol panel. I created a databse from there (name,password and user)

But I go into admner and it says the database (name) doesn't exist and it doesnt appear in the available databases

In adminer I have tried localhost and mysql.server to no avail

Any ideas?

Thx
0
Hi Experts,

How to backup a wordpress website? Back up everything

Thanks
0
I have a category page for sales https://www.theherbsplace.com/product-category/on-sale/ and I need to have the sales listed via product name rather than alphabetical.  For example, I have $2 OFF Aloe Vera, Buy 5 Aloe Vera and a Buy 9 Aloe Vera all with unique sku's.  That's how I would like for them to be sorted but now they are being sorted between other products strictly by the first letter.

https://gyazo.com/debb7bb6186fed2ce3f32b1c0cbd941e

In the above screenshot the middle product Aloe Vera Gel should not be between the 2 Aloe Vera, Whole Leafs.
0
hi,

I am checking the MySQL cluster evaluation guide and i has one terms :

"As MySQL Cluster stores tables in data nodes, rather than in the MySQL Server, there are multiple
interfaces available to access the database."

I think data nodes is MySQL server and MySQL cluster just consist of many MySQL servers, it seems not correct if, according to the statement above.. ?
0
Hi,

Right now want to setup MySQL cluster and MariaDB Galeria Cluster to test the product on how well it function, so in order to prepare for it.

1. How many redhat linux nodes on testing each of this?
2. Anything else needed?
3. no shared storage is needed as actually the testing should not have shared storage and we should try horizontal scale out.
4. anything we should test on  cluster ?
5. can we use only node with 1 x network card to install ProxySQL and test it?
1
Hi,

Right now want to setup MySQL cluster and MariaDB Galeria Cluster to test the product on how well it function, so in order to prepare for it.

1. How many redhat linux nodes on testing each of this?
2. Anything else needed?
3. no shared storage is needed as actually the testing should not have shared storage and we should try horizontal scale out.
4. anything we should test on  cluster ?
5. can we use only node with 1 x network card to install ProxySQL and test it?
0
Hello

What is the Best way to search multiple tables in a MySQL database for Multiple search Terms?

Some Notes
  1. Currently I have it working Fine in MS SQL but have to change to MySQL
  2. The Search is done by Calling a Stored Procedure/Routine
  3. I am using Dynamic SQL to enable all the Search Filter Options
  4. I am also using Parameters to protect against SQL Injection.
  5. Search Columns are both Varchar and Integer
  6. The Procedure is sent 10 search Terms that need to be searched for.

In MSSQL I can use Named Parameters but these aren’t available in MySQL so I would have to pass 60 Parameters to the Prepared Statement.
This would have the Potential for Errors – Ensuring that each Parameter is in the Correct Order!!

How should I do this?

Following it the MSSQL code.
DECLARE @SQLSelectFields NVARCHAR(MAX)	= ''
DECLARE @SQLString NVARCHAR(MAX) = ''
DECLARE @SQLFilter NVARCHAR(MAX) = ''
DECLARE @SQLTables NVARCHAR(MAX) = ''

-- Tables to Select From
SET @SQLTables = ' dbo.PURCHORD_HDR AS POH ' + ' INNER JOIN dbo.ppp_vw_Company C ON C.AccountID = POH.ACCNO AND C.AccountType = 2 '
				+ ' LEFT OUTER JOIN dbo.CONTACTS CO ON CO.SEQNO = POH.CONTACT_SEQNO '
				+ ' LEFT OUTER JOIN dbo.NARRATIVES N ON N.SEQNO = POH.NARRATIVE_SEQNO '


-- Min Fields for General Searching and use
SET @SQLSelectFields = ' POH.SEQNO, POH.STATUS, POH.ORDERDATE, POH.DUEDATE, POH.REFERENCE, POH.ADDRESS1, 

Open in new window

0

MySQL Server

47K

Solutions

23K

Contributors

MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.