473,387 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

run a variable http result

4
I have a php script running querying my database table. it works fine and returns a url from the table see code:

<?
include 'config_inc.php';
include 'error_inc.php';
include 'results_inc.php';

$var = $_GET['q'] ;

$query = "SELECT shape_url FROM shape WHERE shape_id = '".$var."'";

$result = mysql_query($query);
if(mysql_num_rows($result) ==0){
echo $err[3] ,$var;
}
while($row = mysql_fetch_row($result))
{
$shape_url = $row[0];


print "shape_url : $shape_url<br>" ;
}
?>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
the result is
shape_url : http://www.adverts.hecgroup.net/search_mc/shape_45.htm
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^

I have got this code to work ok. But I want the shape_url result to be a variable in the $myfile = file('xxxxxxxxxxx.........

so that when the search result is returned it show as a htm page

<?php
$myfile = file('http://google.com');
foreach ( $myfile as $vals){
print "$vals";
}
?>

any help from any one would be good

ken
Jul 10 '08 #1
4 1372
dlite922
1,584 Expert 1GB
Please use code tags.

I looked at your site. When you display the URLs, when the user clicks on them, instead of visiting the URL, displaying it, you want PHP to grab the contents and give it the user to download ?
Jul 11 '08 #2
hecon
4
Please use code tags.

I looked at your site. When you display the URLs, when the user clicks on them, instead of visiting the URL, displaying it, you want PHP to grab the contents and give it the user to download ?

Hi I think I understand code tags ie <var> makes this a code tags correct ?
The out come I want for my visitor is as follows

visitor searchs via a form "search box" input=text name=q where q is the variable shape-id the query returns the shape_url ie http://xxxxxxxxxxxx

All I have been able to do is display the url What I want is to open the url as a page for the vivitor to view. But the url is not constant and is linked to the var q

I want to be able to insert code to allow the http be a variable

thanks ken


does that make sence ?
Jul 11 '08 #3
Tarantulus
114 100+
I think I know what you want

try:
Expand|Select|Wrap|Line Numbers
  1. $urls[]=$q; //this will add the current query to an array
  2. foreach ( $urls as $file)
  3. $fd=fopen($file, "r"); //this opens the URL
  4. $contents=fread($fd,filesize($file)); //this puts the file contents into a variable
  5. print $contents; //this prints the page
  6.  
  7. }
  8.  
oh and see how my code in this post looks different? thats cos I put it in code tags, you click the # button when writing code in a new post
Jul 11 '08 #4
hecon
4
Hi Hecon or ken back again:

same problem. after querying db the result is returned AOK in the format of
http://www.adverts.hecgroup.net/search_mc/shape_url-45.htm

I have about 200 of these in the db table. I only need one return per search which what I get.

Problem is the the http in not constant ie it chages on each search result

So I need to make the result print to the code below ie chaging the url google,com for my http url for each time a search result is returned.

<?
$myfile = file('http://google.com');
foreach ( $myfile as $vals){
print "$vals";
}
?>

thanks again
Jul 11 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: surrealtrauma | last post by:
the requirement is : Create a class called Rational (rational.h) for performing arithmetic with fractions. Write a program to test your class. Use Integer variables to represent the private data...
5
by: Matt Clepper | last post by:
Any way to do this? I need to call functions based on a variable. Do I actually have to make a case statement and call each funciton explicitly, or is there any way to call a function where the...
5
by: Matt Clepper | last post by:
Any way to do this? I need to call functions based on a variable. Do I actually have to make a case statement and call each funciton explicitly, or is there any way to call a function where the...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
2
by: mengrie | last post by:
Hello, I am writing a small Perl program to atest the availbility of a webservice. So the idea is to call a known method of a known webservice and check the result. To make the program...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.