Solved

Using url variables to query a table which is then passed to an array

Posted on 2008-10-26
3
288 Views
Last Modified: 2012-05-05
I am trying to use URL variables to query a table the result of which is passed to an array for display purposes.

URL string:

detail.php?Type=0&HostID=1&Submit=Submit

Ive been around the block a few times with this trying different things but still cant get it to work.

Any help greatly appreciated.


$maxRows_hostdetail = 10;
$pageNum_hostdetail = 1;
 
 
if (isset($_GET['pageNum_hostdetail'])) {
  $pageNum_hostdetail = $_GET['pageNum_hostdetail'];
}
 
$startRow_hostdetail = $pageNum_hostdetail * $maxRows_hostdetail + 1;
 
 
mysql_select_db($database_webhosting, $webhosting);
 
$query_hostdetail = sprintf("SELECT `Host`, Package, Storage, `Data Transfer`, Bandwidth, `Email Accounts`, `IP Addresses`, `Included Domains`, `Sub Domains`, `Hostable Domains`, `FTP Accounts`, `Domain Price`, `MySQL Databases`, `Shared SSL`, `Dedicated SSL`, UpTime, `Money Back Guarantee`, Support, Setup, Price FROM hostfeatures WHERE `Type` = '%s' AND `Host ID` = '%s' ORDER BY 'Plan ID' ASC ", 
	 $_GET['Type'], 
	  $_GET['Host ID'], 
	$startRow_hostingsearch, 
	$maxRows_hostingsearch);
 
 
$query_limit_hostdetail = sprintf("%s LIMIT %d, %d", $query_hostdetail, $startRow_hostdetail, $maxRows_hostdetail);
$hostdetail = mysql_query($query_limit_hostdetail, $webhosting) or die(mysql_error());
$row_hostdetail = mysql_fetch_assoc($hostdetail);
 
if (isset($_GET['totalRows_hostdetail'])) {
  $totalRows_hostdetail = $_GET['totalRows_hostdetail'];
} else {
  $all_hostdetail = mysql_query($query_hostdetail);
  $totalRows_hostdetail = mysql_num_rows($all_hostdetail);
}
$totalPages_hostdetail = ceil($totalRows_hostdetail/$maxRows_hostdetail)-1;
 
$values = array();
while ($row_hostdetail = mysql_fetch_assoc($hostdetail)) {
    if ( ! $values) {
        foreach ($row_hostdetail as $key => $value) $values[$key] = array($value);
    } else {
        foreach ($row_hostdetail as $key => $value) $values[$key][] = $value;
    }    
}

Open in new window

0
Comment
Question by:betch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:betch
ID: 22808731
Just realized my form was passing HostID, have changed it to Host ID but it still doesn't work.
0
 
LVL 4

Accepted Solution

by:
husker475 earned 500 total points
ID: 22808775
Instead of changing HostID to Host ID, change the key on the $_GET array to HostID,  I think the problem is that a blank space is converted to %20 when it comes to links.

To see what the keys and values really look like, you could use:
echo '<pre>';
print_r($_GET);
echo '</pre>';

Open in new window

0
 

Author Comment

by:betch
ID: 22808798
You Legend husker475, I knew it had to be something stupid - Thanks mate.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question