[Phpsig] Issue with web page display of MySQL values
bill
phpsig@kalamazoolinux.org
Thu, 12 Sep 2002 15:16:28 -0400
More questions:
Why do you have four queries in lines 94 - 112 that are essentially the same?
For example, if you changed line 107 to be
$num_rows = mysql_num_rows($show);
you could eliminate an entire query (lines 96, 101, & 106).
Why do all the queries only look at one table, ipaddress? Are you intending on
getting information from the other tables site and device? If so, you have to call
them, changing this:
SELECT * from ipaddress WHERE $wherez LIKE \"%$search%\"
to this
SELECT * from ipaddress, site
WHERE site_name LIKE \"%$search%\"
AND ipaddress.siteid=site.siteid
randall perry wrote:
> I was helping a student with a project, and I am near the end of my
> expertise on PHP and MySQL (the class was on neither). I gave him some
> code and helped him make the initial site, but now he is looking to improve
> it, and I am not much help here.
>
> Take a look:
> http://www.domain-logic.com/class/Davenport/cis241/view.php
>
> Device Type and Site should pull up their respective links in this view and
> not their numbers.
> Here is the database schema:
>
> mysql> show tables;
> +---------------------+
> | Tables_in_ipaddress |
> +---------------------+
> | device |
> | ipaddress |
> | site |
> +---------------------+
>
> mysql> describe device;
> +----------+-------------+------+-----+---------+----------------+
> | Field | Type | Null | Key | Default | Extra |
> +----------+-------------+------+-----+---------+----------------+
> | devtype | varchar(15) | | UNI | | |
> | typecode | smallint(6) | | PRI | NULL | auto_increment |
> +----------+-------------+------+-----+---------+----------------+
> 2 rows in set (0.00 sec)
>
> mysql> describe ipaddress;
> +----------+-------------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +----------+-------------+------+-----+---------+-------+
> | ip_add | varchar(15) | | PRI | 0.0.0.0 | |
> | ufname | varchar(30) | YES | | NULL | |
> | ulname | varchar(30) | YES | | NULL | |
> | devname | varchar(30) | YES | | NULL | |
> | typecode | smallint(6) | YES | | NULL | |
> | siteid | smallint(6) | YES | | NULL | |
> | appl | varchar(35) | YES | | NULL | |
> +----------+-------------+------+-----+---------+-------+
> 7 rows in set (0.00 sec)
>
> mysql> describe site;
> +-----------+-------------+------+-----+---------+----------------+
> | Field | Type | Null | Key | Default | Extra |
> +-----------+-------------+------+-----+---------+----------------+
> | site_name | varchar(40) | | UNI | | |
> | siteid | smallint(6) | | PRI | NULL | auto_increment |
> +-----------+-------------+------+-----+---------+----------------+
> 2 rows in set (0.00 sec)
>
> I also made some links to the source code. Hey Paul! Take a look and maybe
> learn something (or maybe you are already past this?)
> Randall Perry
> www.fasnap.com
> www.Davenport.edu
>
> --------------------------------------------------------------------------------
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.385 / Virus Database: 217 - Release Date: 9/4/2002