Hi i would like to know is there anyway to not show the following information if the user does not type in
stock:(then stock)
here is my code the url looks like
http://www.example.com/search?q=stock:msft
or
http://www.example.com/search?=stock:goog
what I need is to take the part after : and past that where the s=msft is.
{code saved}
<!– this is our table which displays the stock info –>
<!– we access the individual items by using $data[0]–>
<table>
<tr><td>description</td><td>latest figure</td><tr>
<tr><td>symbol</td><td><?php echo $data[0] ?></td></tr>
<tr><td>last price</td><td><?php echo $data[1] ?></td></tr>
<tr><td>date</td><td><?php echo $data[2] ?></td></tr>
<tr><td>time</td><td><?php echo $data[3] ?></td></tr>
<tr><td>change</td><td><?php echo $data[4] ?></td></tr>
<tr><td>open</td><td><?php echo $data[5] ?></td></tr>
<tr><td>high</td><td><?php echo $data[6] ?></td></tr>
<tr><td>low</td><td><?php echo $data[7] ?></td></tr>
<tr><td>volume</td><td><?php echo $data[8] ?></td></tr>
</table>
<?php
//close the filehandle $fp
fclose ($fp);
?>Thanks


Hi Russell, The trick here
Hi Russell,
The trick here is to use PHP's explode() function to separate your query into parts delimited by the ":" character, and then study part 0 to see if it is one of your function keywords (e.g. "stock") and if so process the data value in part 1. For example, where your query is in the $q variable:
$parts = explode(":",$q);switch($parts[0])
{
case "stock":
// code to handle stock quote in $parts[1] here
break;
default:
// code to handle normal query here
break;
}
Cheers,
David.
David, You Rock! But now a
David, You Rock!
But now a second question.
If a user types in stock:apple i would like to to look into our DB and find the stock simple AAPL
if they type in the Stock Simple stock:AAPL i would like it to just go to the net step and not look into the DB.
Is that possible?
Thanks
Hello Russell, Without
Hello Russell,
Without having an entire static array of valid Stock Simple values; it would be necessary to go to the database anyway; so I would combine the steps - simply selecting based on company name or Stock Simple; for example:
case: "stock":$sql = "SELECT * FROM companies WHERE
name LIKE '%".mysql_escape_string($parts[1])."%'
OR
simple='".mysql_escape_string($parts[1])."'";
etc... something like that...
Hope this helps!
Cheers,
David.
Thanks david. I am making a
Thanks david.
I am making a flex flash file to show all the quotes that we have in the DB. - this data will be printed in a xml file but saved inside a php file
What I need is somehow to get the $_GET[q] sent to the following part of my code
<mx:HTTPService id="stockInfo" url="data/stock.php"result="dataResult(event)" fault="faultResult(event)" resultFormat="object" />
Somehow I need to get the AAPL or any stock quote sent to that stock.php file though the flash file.
I have spent 2 hours looking and cant seem to find it, if you can help that would be great!
Thanks
**This post has been
**This post has been FIXED***
- Correct example at bottom
Hey All,
just wondering there seems to be an error when I do the following
The error is that it is showing both Radio and the Stock when it should only be showing one or the other.
I noticed when i typed Stock instead of stock it would not show, so I thought it would be a simple OR statement or a || I also tried AND
<?php
$parts = explode(":",$q);
switch($parts[0])
{
case ("radio" || "Radio"):
//code
break;
}
$parts = explode(":",$q);
switch($parts[0])
{
case ("stock" || "Stock"):
//code
break;
}
?>
Correct way of doing case
<?php
$parts = explode(":",$q);
switch($parts[0])
{
case "radio":
case "Radio":
//code
break;
}
?>
Hope that helps others