Jump to content

Save an echo in MySQL?


MDanz

Recommended Posts

You can do it like this:

 

$result = mysql_real_escape_string($result);
mysql_query("UPDATE `table_name` SET `some_column` = '$result' WHERE `some_column` = 'Some Value'");

 

umm i don't quite understand. This is my table below.  When you mean table_name, some_column , some_value, i don't know what your referring too.  That is the table i echo below.  I need that in the mysql database.  Is your way the correct way of doing it?

 

 

echo '<br><table '.$margin.'>';

 

      while ($runrows = mysql_fetch_assoc($run))

    {

              //get data

        $name = $runrows['name'];

        $image = $runrows['image'];

        $hyperlink = $runrows['hyperlink'];

        $currency = $runrows['currency'];

        $info = $runrows['info'];

        $type = $runrows['type'];

 

 

 

        echo '<tr><td>';

switch ($type) {

    case 'I':

        echo '<img src="http://www.u-stack.com/Image.jpg">';

        break;

    case 'M':

        echo '<img src="http://www.u-stack.com/Music.jpg">';

        break;

    case 'F':

        echo '<img src="http://www.u-stack.com/File.jpg">';

        break;

    case 'V':

        echo '<img src="http://www.u-stack.com/Video.jpg">';

        break;

        case 'J':

        echo '<img src="http://www.u-stack.com/Job.jpg">';

        break;

        case 'D':

        echo '<img src="http://www.u-stack.com/Discussion.jpg">';

        break;

        case 'P':

        echo '<img src="http://www.u-stack.com/Product.jpg">';

        break;

 

 

 

}  echo '</td></tr>';

 

 

 

    }

 

   

    echo '</table>';

 

is Some_Value.. where i input the echo?

i've been asking the same question all night, so this the best i can think of.

 

 

what i have is a search engine. say i search for car and it displays a car. then i search for house and it displays a house.  i don't want the car search to be removed. I want it to display both old and new. Its a multiple search function.  When i post the full code for help, i dont get the help i need.

 

so i was thinking save the result in a database.. it might not be the best idea.  i tried array_push but i don't know where to place it in my code.

 

 

<?php

//get data

 

 

 

 

$button = $_GET['submit'];

$search = $_GET['search'];

 

 

if

 

(!$button)

echo "You didn't submit a keyword";

 

else

{

if(!isset($search) ||  strlen($search)<=2)

echo "<br><font color=white>search term too short</font>";

else

{

echo "<br><br><font color=white>you searched for <b>$search</b></font><hr size='1'>";

}

mysql_connect("localhost", "Master", "password");

mysql_select_db("Login");

 

 

//explode our search term

$search_exploded = explode(" ",$search);

foreach($search_exploded as $search_each)

{

//construct query

$x++;

if($x==1)

        $construct .= "keywords LIKE '$search_each'";

        else

        $construct .= "OR keywords LIKE '$search_each'";

}

 

                  //echo out $construct

$construct = "SELECT * FROM Upload WHERE $construct";

}              $run = mysql_query($construct);

                $foundnum =  mysql_num_rows($run);

 

 

if  ($foundnum==0)

echo "<br><br><font color=white>No Stacks Found</font>";

else

{

    echo "<font color=white>$foundnum Stacks Found!</font><p>";

if($_GET['RadioGroup1']== 1 )

$margin = 'style="margin-left:60px"';

else if($_GET['RadioGroup1']== 2 )

$margin = 'style="margin-left:120px"';

else if($_GET['RadioGroup1']== 3 )

$margin = 'style="margin-left:180px"';

else if($_GET['RadioGroup1']== 4 )

$margin = 'style="margin-left:240px"';

else if($_GET['RadioGroup1']== 5 )

$margin = 'style="margin-left:300px"';

else if($_GET['RadioGroup1']== 6 )

$margin = 'style="margin-left:360px"';

else if($_GET['RadioGroup1']== 7 )

$margin = 'style="margin-left:420px"';

else if($_GET['RadioGroup1']== 8 )

$margin = 'style="margin-left:480px"';

else

$margin = 'style="margin-left:0px"';

 

 

 

echo '<br><table '.$margin.'>';

 

      while ($runrows = mysql_fetch_assoc($run))

    {

              //get data

        $name = $runrows['name'];

        $image = $runrows['image'];

        $hyperlink = $runrows['hyperlink'];

        $currency = $runrows['currency'];

        $info = $runrows['info'];

        $type = $runrows['type'];

 

 

 

        echo '<tr><td>';

switch ($type) {

    case 'I':

        echo '<img src="http://www.u-stack.com/Image.jpg">';

        break;

    case 'M':

        echo '<img src="http://www.u-stack.com/Music.jpg">';

        break;

    case 'F':

        echo '<img src="http://www.u-stack.com/File.jpg">';

        break;

    case 'V':

        echo '<img src="http://www.u-stack.com/Video.jpg">';

        break;

        case 'J':

        echo '<img src="http://www.u-stack.com/Job.jpg">';

        break;

        case 'D':

        echo '<img src="http://www.u-stack.com/Discussion.jpg">';

        break;

        case 'P':

        echo '<img src="http://www.u-stack.com/Product.jpg">';

        break;

 

 

 

}  echo '</td></tr>';

 

 

 

    }

 

   

    echo '</table>';

 

 

 

}

 

 

 

?>

 

this is my full code for the working search. I'm not asking for you to do it for me, i'm just having trouble implementing keeping the old results displayed while displaying the new ones.

@MDanz - We're just trying to help here man, (I know I haven't provided you any help) but please remember this is a FREE forum with many people who are more than willing to help you out if you allow them to. TLG is trying to.

 

srry wasn't meant to be rude.. just frustrated

@MDanz - We're just trying to help here man, (I know I haven't provided you any help) but please remember this is a FREE forum with many people who are more than willing to help you out if you allow them to. TLG is trying to.

 

srry wasn't meant to be rude.. just frustrated

well it doesnt seem practical you want to save search results in the table as it is already in your database. So why dont you save each keyword user searches in another table, and later select all search items with these keywords?

i've found a new way to implement what i'm trying to do, maybe you can help me..

 

 

http://www.phpfreaks.com/forums/index.php/topic,263873.0.html

 

 

i'm new to php, so i am slow with it...

The link you have given seems to have nothing to do with your problem? To get answer quick your question should be short and clear.

in short as possible;  search new data while keeping old data on the page

Well got it now, you would have tell this before, its clear now.

 

if you want to use array_push to store search keyword then

 

$searchword=$_POST["txtsearch"];

if(is_array($keyword) && count($keyword)>0)

{

      array_push($keyword,$searchword);

}else{

      $keyword=array($searchword);

}

//now you can loop through the array to display new as well as old search items

i've tried this before...its not the keyword, its the results. The results are echoed into a table.  So i would have to store the whole table in the array.  This way is too complicated for me.

 

 

the new way i'm doing it is 2 layers each with a submit button.  radiobutton1 brings forward layer1 and radiobutton2 brings forward layer2.  it's much easier for what i'm trying to accomplish.  Thanks for the help i appreciate it. btw any idea how to bring a layer to the front?

 

 

i've tried this before...its not the keyword, its the results. The results are echoed into a table.  So i would have to store the whole table in the array.  This way is too complicated for me.

 

 

the new way i'm doing it is 2 layers each with a submit button.  radiobutton1 brings forward layer1 and radiobutton2 brings forward layer2.  it's much easier for what i'm trying to accomplish.  Thanks for the help i appreciate it. btw any idea how to bring a layer to the front?

well the hint is you got to play with z-index. If z-index of layer1 is more than layer2...layer 1 is shown infront. Try this

<script language="javascript" type="text/javascript">

function radioBtn1Click(){

    document.getElementById("layer1").style.z-index=10;

    document.getElementById("layer2").style.z-index=5;

}

 

function radioBtn2Click(){

    document.getElementById("layer2").style.z-index=10;

    document.getElementById("layer1").style.z-index=5;

}

</script>

call first function on radio button click to show layer1 infront, second function to show layer2

infront

 

hope this will help you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.