hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : MySQL $_GET help needed
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

MySQL $_GET help needed

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 03-31-2004, 03:55 PM
ballingtonma ballingtonma is offline
Junior Guru
 
Join Date: May 2003
Posts: 186

MySQL $_GET help needed


Hi, i am trying to set up this function to call "cat" from the browsers window, the table should try to find its value and include the corrisponding file. But if it doesnt exist i want it to just use the default value for $cat so the file include can just call this.

Here is the code thats not working:
PHP Code:
<?
$cat 
$_GET['cat'];
$result mysql_query("SELECT * FROM tablename WHERE category = '$cat' LIMIT 1");
if (!
$result) { // if it didnt find the $cat content in the table
$col2 "default";
}
else { 
// else if i did find the $cat content in the table
while ( $row mysql_fetch_array($result) ) {
$col2 $row["col2"];
}
}
require_once(
"folder/".$col2."/file.php");
?>
Thanks in Advance,
Matt

__________________
http://www.theextremenetwork.com
MSN: webmaster@theextremenetwork.com

Reply With Quote


Sponsored Links
  #2  
Old 03-31-2004, 04:56 PM
Gleem Gleem is offline
Newbie
 
Join Date: Jan 2001
Posts: 21
Are the results you are searching for located in "col2" of your table? If so, you could change your query to include the name of the column that has your result(col2). This way you will isolate the variable and then call it in your array using $row[0].

Not sure if that fixes everything, just some thoughts.

PHP Code:
<? 
$cat 
$_GET['cat']; 
$result mysql_query("SELECT columnName FROM tablename WHERE category = '$cat' LIMIT 1"); 
$col2 "default"//Set as default - no if needed
if { // if $cat content matches
$row mysql_fetch_array($result); // you wouldn't need a loop for one result
$col2 $row[0]; 

require_once(
"folder/".$col2."/file.php"); 
?>

__________________
Gleem Studios
www.gleem.com

Reply With Quote
  #3  
Old 03-31-2004, 05:42 PM
ballingtonma ballingtonma is offline
Junior Guru
 
Join Date: May 2003
Posts: 186
Thanks, thats really helpfull!!

__________________
http://www.theextremenetwork.com
MSN: webmaster@theextremenetwork.com

Reply With Quote
Sponsored Links
Reply

Related posts from TheWhir.com
Title Type Date Posted
Web Host Rackspace Launches Private Beta for MySQL Cloud Database Web Hosting News 2011-12-01 21:09:51
Parallels Now Offering Licenses for CloudLinux OS Web Hosting News 2011-10-26 17:29:25
Web Hosting Sales and Promos Roundup - October 7, 2011 Web Hosting News 2011-10-07 19:56:18
Web Hosting Software Firm CloudLinux Releases CloudLinux OS Version 6.1 Web Hosting News 2011-09-13 14:08:49
Web Host FireHost Partners with Cloud Security Firm Gazzang for Data Encryption Web Hosting News 2011-08-16 20:33:43


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?