MySQL PHP Forum
GEtting the value of a selected listbox item (3 replies)
<?php
//Establish connection
$query = "SELECT Matric_No FROM civil_2005_2006_sem1_yr1" or die (mysql_error());
$sql = mysql_query($query);
print "<p>Select MatNo: \n";
print "<select name=\"MatricNo\" > \n";
while ($row = mysql_fetch_array($sql))
{
$Matric_No = $row["Matric_No"];
// Echo your rows here...
print "<option value=$Matric_No>$Matric_No\n";
}
print "</select>\n";
>?
//Establish connection
$query = "SELECT Matric_No FROM civil_2005_2006_sem1_yr1" or die (mysql_error());
$sql = mysql_query($query);
print "<p>Select MatNo: \n";
print "<select name=\"MatricNo\" > \n";
while ($row = mysql_fetch_array($sql))
{
$Matric_No = $row["Matric_No"];
// Echo your rows here...
print "<option value=$Matric_No>$Matric_No\n";
}
print "</select>\n";
>?
Best Mysql structure (no replies)
Ok all I need some quick help on this one.
I have a table say
ID, FirstName, LastName, Recruiter_ID
Which contains a rep's information and the ID of the person recruiting from the same table.. So let's take an example
ID 1000 recruits 1001, and 1001 recruits 1002 but 1000 needs to get credit for the whole volume 1001 and 1002 create.
So
1000
|
1001
|
1002
1003
1004
|
1005
1006
etc.
What would be the best structure to find all of the ID's of recruits brought on by anyone under 1001?
Hope this makes sense?
Thanks!
William
I have a table say
ID, FirstName, LastName, Recruiter_ID
Which contains a rep's information and the ID of the person recruiting from the same table.. So let's take an example
ID 1000 recruits 1001, and 1001 recruits 1002 but 1000 needs to get credit for the whole volume 1001 and 1002 create.
So
1000
|
1001
|
1002
1003
1004
|
1005
1006
etc.
What would be the best structure to find all of the ID's of recruits brought on by anyone under 1001?
Hope this makes sense?
Thanks!
William
Access online server’s db via local php (no replies)
Hi,
how do i access my online server’s db via a local php app ?
it would be most usefull for me to work directly on the db with other remote developers together ... instead of syncing the db manually each time.
How is that achieved ? I use dreamhost, cakephp and Dreamweaver as of now.
Pls share.
Best regards,
Frank
how do i access my online server’s db via a local php app ?
it would be most usefull for me to work directly on the db with other remote developers together ... instead of syncing the db manually each time.
How is that achieved ? I use dreamhost, cakephp and Dreamweaver as of now.
Pls share.
Best regards,
Frank
Indexing is done for single table, but its not working for most of the queries. (1 reply)
Hi,
I have created the index for the below table, but its not working correctly for some queries, I don't know where I have done mistake, please help me.
For the query, "explain select * from videos_ctgryDomain where domain = 1;", its scanning all the rows in the table, but for other domains, its coming correctly.
mysql> desc videos_ctgryDomain;
+--------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+-------+
| domain | int(11) | NO | MUL | NULL | |
| ctgry | int(11) | NO | | NULL | |
+--------+---------+------+-----+---------+-------+
2 rows in set (0.01 sec)
mysql> select * from videos_ctgryDomain;
+--------+-------+
| domain | ctgry |
+--------+-------+
| 9 | 9 |
| 9 | 5 |
| 3 | 14 |
| 3 | 12 |
| 1 | 4 |
| 1 | 2 |
| 1 | 14 |
| 1 | 12 |
+--------+-------+
8 rows in set (0.00 sec)
mysql> show index from videos_ctgryDomain;
+--------------------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------------------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| videos_ctgryDomain | 1 | indx_domain | 1 | domain | A | 8 | NULL | NULL | | BTREE | | |
+--------------------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.00 sec)
mysql> explain select * from videos_ctgryDomain where domain = 1;
+----+-------------+--------------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | videos_ctgryDomain | ALL | indx_domain | NULL | NULL | NULL | 8 | Using where |
+----+-------------+--------------------+------+---------------+------+---------+------+------+-------------+
mysql> explain select * from videos_ctgryDomain where domain = 3;
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
| 1 | SIMPLE | videos_ctgryDomain | ref | indx_domain | indx_domain | 4 | const | 2 | NULL |
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
mysql> explain select * from videos_ctgryDomain where domain = 9;
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
| 1 | SIMPLE | videos_ctgryDomain | ref | indx_domain | indx_domain | 4 | const | 2 | NULL |
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
Thanks in advance.
I have created the index for the below table, but its not working correctly for some queries, I don't know where I have done mistake, please help me.
For the query, "explain select * from videos_ctgryDomain where domain = 1;", its scanning all the rows in the table, but for other domains, its coming correctly.
mysql> desc videos_ctgryDomain;
+--------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+-------+
| domain | int(11) | NO | MUL | NULL | |
| ctgry | int(11) | NO | | NULL | |
+--------+---------+------+-----+---------+-------+
2 rows in set (0.01 sec)
mysql> select * from videos_ctgryDomain;
+--------+-------+
| domain | ctgry |
+--------+-------+
| 9 | 9 |
| 9 | 5 |
| 3 | 14 |
| 3 | 12 |
| 1 | 4 |
| 1 | 2 |
| 1 | 14 |
| 1 | 12 |
+--------+-------+
8 rows in set (0.00 sec)
mysql> show index from videos_ctgryDomain;
+--------------------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------------------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| videos_ctgryDomain | 1 | indx_domain | 1 | domain | A | 8 | NULL | NULL | | BTREE | | |
+--------------------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.00 sec)
mysql> explain select * from videos_ctgryDomain where domain = 1;
+----+-------------+--------------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | videos_ctgryDomain | ALL | indx_domain | NULL | NULL | NULL | 8 | Using where |
+----+-------------+--------------------+------+---------------+------+---------+------+------+-------------+
mysql> explain select * from videos_ctgryDomain where domain = 3;
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
| 1 | SIMPLE | videos_ctgryDomain | ref | indx_domain | indx_domain | 4 | const | 2 | NULL |
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
mysql> explain select * from videos_ctgryDomain where domain = 9;
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
| 1 | SIMPLE | videos_ctgryDomain | ref | indx_domain | indx_domain | 4 | const | 2 | NULL |
+----+-------------+--------------------+------+---------------+-------------+---------+-------+------+-------+
Thanks in advance.
query to list tables according to relationship (1 reply)
what is the query to list all tables in a schema with relation?
for example:
schema_name
table1
id
name
table2_id
table2
id
name
table3
id
name
table2_id
so that the result arrangement is : table2, table1 then table3 or table2, table3 then table1
for example:
schema_name
table1
id
name
table2_id
table2
id
name
table3
id
name
table2_id
so that the result arrangement is : table2, table1 then table3 or table2, table3 then table1
Creating an array variable from SQL results to use with NOT IN() function. (1 reply)
I'm trying to create an array variable from a simple SQL query to use in a NOT IN() function in another SQL query. I have an ID field in Table 2 that corresponds to an ID field in Table 1. The relationship is Table 1 one to Table 2 many. I have been successful creating the second SQL query however, I only get the last ID from Table 2.
Here is an example of my code:
$query = "SELECT * FROM Table2 WHERE `mbr_member_id` = '$v_mbr_id'";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
$variable = $row['friend_of'];
}
$rand_mbr = "SELECT * FROM Table1 WHERE `act`='Y' AND `lck`='N' AND `member_id` != '$v_mbr_id' AND `member_id` NOT IN ('$variable') ORDER BY RAND() LIMIT 5";
Any help would be greatly appreciated.
Here is an example of my code:
$query = "SELECT * FROM Table2 WHERE `mbr_member_id` = '$v_mbr_id'";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
$variable = $row['friend_of'];
}
$rand_mbr = "SELECT * FROM Table1 WHERE `act`='Y' AND `lck`='N' AND `member_id` != '$v_mbr_id' AND `member_id` NOT IN ('$variable') ORDER BY RAND() LIMIT 5";
Any help would be greatly appreciated.
I am new in Php Coding can any one please help me "PHP code to display specific column(eg column "C" complete record) of .xls format to display on web page" (no replies)
Its very urgent, I tried with multiple sample code from google....I got all the data of excel in output, But I need only "specific column" complete record on webpage
??????? (no replies)
<a href="http://mqysh.net/">???????</a>http://mqysh.net/
<a href="http://mqysh.net/">???????</a>http://mqysh.net/
<a href="http://mqysh.net/">???????</a>http://mqysh.net/
<a href="http://mqysh.net/">??????????</a>http://mqysh.net/
<a href="http://www.taebh.com/">???????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">?????????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">?????????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">???????</a>http://www.taebh.com/
http://mqysh.net/
http://www.taebh.com/
<a href="http://mqysh.net/">???????</a>http://mqysh.net/
<a href="http://mqysh.net/">???????</a>http://mqysh.net/
<a href="http://mqysh.net/">??????????</a>http://mqysh.net/
<a href="http://www.taebh.com/">???????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">?????????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">?????????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">???????</a>http://www.taebh.com/
http://mqysh.net/
http://www.taebh.com/
Web Designing Chennai (no replies)
The studio was founded in 2004 in Chennai.We offer web site design and web designing Chennai, Spotlight media Chennai providing the services are Website Design, Web Development, Flash Design, SEO Services effectively at affordable cost.
Fatal error: Allowed memory size (2 replies)
Hi,
I am using shared server for my website and receiving the following error.
Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 24 bytes) in /home/abc/xyz/classes/dbclass.php on line 53
Need your support in resolving this.
I am using shared server for my website and receiving the following error.
Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 24 bytes) in /home/abc/xyz/classes/dbclass.php on line 53
Need your support in resolving this.
Unable to resolve fatal error: (3 replies)
I have successfully installed php and MySQL with Apache server and I believe all are working fine together.
I am trying to connect to my MYSQL database via php, I have used this code to do that, but I get a fatal error:
//connect to a single database
$con=mysqli_connect("localhost", "root", "1234", "SIGN-TECH");
//check connection
if (mysqli_connect_err($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?
Fatal error: Call to undefined function mysqli_correct_err() in C:\Apache24\htdocs\mysql_connect2.php on line 7
When I look at my php info I have this enabled, I read elsewhere to check to make sure of this and it is enabled:
mcrypt support enabled
mcrypt_filter support enabled
Version 2.5.8
Api No 20021217
Supported ciphers cast-128 gost rijndael-128 twofish cast-256 loki97 rijndael-192 saferplus wake blowfish-compat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes arcfour
Supported modes cbc cfb ctr ecb ncfb nofb ofb stream
Directive Local Value Master Value
mcrypt.algorithms_dir no value no value
mcrypt.modes_dir no value no value
I am trying to connect to my MYSQL database via php, I have used this code to do that, but I get a fatal error:
//connect to a single database
$con=mysqli_connect("localhost", "root", "1234", "SIGN-TECH");
//check connection
if (mysqli_connect_err($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?
Fatal error: Call to undefined function mysqli_correct_err() in C:\Apache24\htdocs\mysql_connect2.php on line 7
When I look at my php info I have this enabled, I read elsewhere to check to make sure of this and it is enabled:
mcrypt support enabled
mcrypt_filter support enabled
Version 2.5.8
Api No 20021217
Supported ciphers cast-128 gost rijndael-128 twofish cast-256 loki97 rijndael-192 saferplus wake blowfish-compat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes arcfour
Supported modes cbc cfb ctr ecb ncfb nofb ofb stream
Directive Local Value Master Value
mcrypt.algorithms_dir no value no value
mcrypt.modes_dir no value no value
??????? (no replies)
<a href="http://mqysh.net/">???????</a>http://mqysh.net/
<a href="http://mqysh.net/">???????</a>http://mqysh.net/
<a href="http://mqysh.net/">???????</a>http://mqysh.net/
<a href="http://mqysh.net/">??????????</a>http://mqysh.net/
<a href="http://www.taebh.com/">???????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">?????????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">?????????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">???????</a>http://www.taebh.com/
http://mqysh.net/
http://www.taebh.com/
<a href="http://mqysh.net/">???????</a>http://mqysh.net/
<a href="http://mqysh.net/">???????</a>http://mqysh.net/
<a href="http://mqysh.net/">??????????</a>http://mqysh.net/
<a href="http://www.taebh.com/">???????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">?????????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">?????????</a>http://www.taebh.com/
<a href="http://www.taebh.com/">???????</a>http://www.taebh.com/
http://mqysh.net/
http://www.taebh.com/
SQL with multiple join conditions... (3 replies)
Hi,
I have a problem getting a query to work.
I have two tables like this:
#pricing#
ID - parent - material - lam - price
1 - 22 - test - 1 - 10
2 - 22 - test - 0 - 8
#pricing_ug#
ID - material - lam - ugprice
1 - test - 1 - 9
1 - test - 0 - 7
My query looks like this:
SELECT `pricing`.*, `pricing_ug`.`ugprice`
FROM (`pricing`)
LEFT JOIN `pricing_ug` ON
`pricing_ug`.`material` = `pricing`.`material`
AND `pricing_ug`.`lam` = `pricing`.`lam`
WHERE `pricing`.`parent` = '22'
The query works perfect with one of the conditions ( whether material = material or lam = lam ) but I need them both.
Can you give me any tips how to achive that?
Thanks a lot in advance!
I have a problem getting a query to work.
I have two tables like this:
#pricing#
ID - parent - material - lam - price
1 - 22 - test - 1 - 10
2 - 22 - test - 0 - 8
#pricing_ug#
ID - material - lam - ugprice
1 - test - 1 - 9
1 - test - 0 - 7
My query looks like this:
SELECT `pricing`.*, `pricing_ug`.`ugprice`
FROM (`pricing`)
LEFT JOIN `pricing_ug` ON
`pricing_ug`.`material` = `pricing`.`material`
AND `pricing_ug`.`lam` = `pricing`.`lam`
WHERE `pricing`.`parent` = '22'
The query works perfect with one of the conditions ( whether material = material or lam = lam ) but I need them both.
Can you give me any tips how to achive that?
Thanks a lot in advance!
