PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Oct 14, 2019 9:15 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun May 13, 2012 4:11 pm 
Offline
Forum Newbie
User avatar

Joined: Sun Sep 12, 2010 7:43 pm
Posts: 5
Hello,

I was looking for a script to get items from ENUM column in MySQL. I found some LONG, EXTENSIVE scripts on how to do it on the Internet. Those scripts used a variety of functions and variables. I didn't even understand it :lol: . I took the idea from those scripts and created a script on my own - concise and short.

Now, I wonder at how short it is in comparison with those ones on the Internet. What do you think of my script?

Syntax: [ Download ] [ Hide ]
<?php

//connect to database
require_once('../base.php');


$query = "show columns from goods like 'producer'";

$r = mysqli_query($connect, $query);


$row = mysqli_fetch_array($r);


$en = $row['Type'];

//change every unwanted character to nothing.
$table = array('enum'=>'',','=>' ','('=>'',')'=>'',"'"=>'');

$en2 = strtr($en,$table);


$table = explode(" ",$en2);

#print_r($table);
echo 'We have the following ENUM values: ';

foreach($table as $v){
echo '<b>'.$v.' </b>';
}

?>


Is it alright?


Top
 Profile  
 
PostPosted: Tue May 15, 2012 7:57 am 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2794
Location: .za

have a look at this url, it might be helpful

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group