PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I need to create a query taking specific colum data (IP, IP1, IP2, IP3 etc.) within my database however I do not know how to do this. Here is my code so far and explainations;
$db = mysql_connect("localhost","","") or die("Problem connecting");
mysql_select_db("audit") or die("Problem selecting database");
$ips = //this sets the variable to all of the IP colums withi nthe database
$query = "SELECT '$ips' FROM dedicated"; //$query looks through the ips
$result = mysql_query($query) or die ("Query failed"); //$result holds all of the found IP addresses
$numofrows = mysql_num_rows($result); //Counts number of rows from $result
I will eventually output the data using an echo statement.
is there a reason your table design isn't normalized? i.e. having unknown multiple columns storing the same type of information often isn't best practice.
a table where each row contains a single IP is most flexible. If this existing table holds other information, then yes, a seperate table is preferred, with a linking field that points to which row in the existing table the IP relates to.