Jump to content

mikefrederick

Members
  • Posts

    247
  • Joined

  • Last visited

    Never

Posts posted by mikefrederick

  1. I have this site at truegraphic.com/vrental that I am developing and I am willing to pay someone $40 to do the following two things:

     

    when people add a property they insert 9 images and then that info is retrieved at pages such as this:

     

    http://www.truegraphic.com/vrental/proplist.php?idprop=44

     

    What I need is someone to implement the file_exist function to the images on the page so that if they do not exist, they simply do not show up rather than having the box w/ the x in the corner show up.

     

     

    The second thing I need done occurs at:

    http://www.truegraphic.com/vrental/admin/manage_cities.php

     

    The region is chosen from a database of regions, as is the country and state. Right now the 3 select boxes show all of the regions, all the countries, and all of the states. What I need is when someone selects a region, the countries are repopulated based on the region, and then when you choose a country the states are repopulated based on the country, and then you can add a city to that state. Keep in mind all the databases already exist and everything.

  2. I do not know how to use that function in this case. It detects that it exists everytime I think. My problem basically is that the page that the images are displayed on displayes boxes with x's where the image should be if it was not uploaded .I tried the following with no success:

     

    $filename = 'propertyimages/'.$_row_Rs['imageone'];

     

    if (file_exists($filename)) { echo '<img src="propertyimages/'.$row_Rs['imageone'].'" height="200" width="200" vspace="10" hspace="10" >'; }

    else {

        echo " ";

    }

     

     

  3. How can I display an image w/ php only if it exists. the images are uploaded via a user, and the image is placed in a folder called propertyimages and the image name is placed in a table called image1 inside of a database. then when it comes time for them to be displayed, I am connecting to the database and using the following script to show the image:

     

    <? echo '<img src="propertyimages/'.$row_Rs['imageone'].'" height="200" width="200" vspace="10" hspace="10" >'; ?>

     

    now how can I alter this so that it will only show if it actually exists?

  4. help please, this is the second time I posted this, I can't figure out how to upload multiple files. I have the form w/ 2 upload fields called image1 and image2. Then I am using this script which will upload the file names to a database and it will upload the first file to a folder on the site called "propertyimages/" and I need to know how to make the script also copy the other file to the folder. here is the script, which contains some additional information being submitted to the db:

     

     

    <?php

    require_once "connect.php";

     

    $filename = $HTTP_POST_FILES['image1']['name'];

    $filenametwo = $HTTP_POST_FILES['image2']['name'];

     

    $path= "../propertyimages/".$filename;

    $pathtwo= "../propertyimages/".$filenametwo;

    if (copy($HTTP_POST_FILES['image1']['tmp_name'], $path))

    {

     

    $addname = $_POST['Addname'];

    $addemail = $_POST['Addemail'];

    $addphone = $_POST['Addphone'];

    $adddesc = $_POST['Adddesc'];

    $addact = $_POST['Addact'];

    $addrates = $_POST['Addrates'];

    $addamen = $_POST['Addamen'];

     

     

    mysql_select_db($database_localhost, $localhost);

    $query = "INSERT INTO addnew (addname,addemail,addphone,adddesc,addamen,addact,addrates,imageone,imagetwo) VALUES('$addname','$addemail','$addphone','$adddesc','$addamen','$addact','$addrates','$filename','$filenametwo')";

    $Rs = mysql_query($query, $localhost) or die(mysql_error());

     

     

    Header ('Location:index.php');

     

    }

    ?>

  5. help please, I can't figure out how to upload multiple files. I have the form w/ 2 upload fields called image1 and image2. Then I am using this script which will upload the file names to a database and it will upload the first file to a folder on the site called "propertyimages/" and I need to know how to make the script also copy the other file to the folder. here is the script, which contains some additional information being submitted to the db:

     

     

    <?php

    require_once "connect.php";

     

    $filename = $HTTP_POST_FILES['image1']['name'];

    $filenametwo = $HTTP_POST_FILES['image2']['name'];

     

    $path= "../propertyimages/".$filename;

    $pathtwo= "../propertyimages/".$filenametwo;

    if (copy($HTTP_POST_FILES['image1']['tmp_name'], $path))

    {

     

    $addname = $_POST['Addname'];

    $addemail = $_POST['Addemail'];

    $addphone = $_POST['Addphone'];

    $adddesc = $_POST['Adddesc'];

    $addact = $_POST['Addact'];

    $addrates = $_POST['Addrates'];

    $addamen = $_POST['Addamen'];

     

     

    mysql_select_db($database_localhost, $localhost);

    $query = "INSERT INTO addnew (addname,addemail,addphone,adddesc,addamen,addact,addrates,imageone,imagetwo) VALUES('$addname','$addemail','$addphone','$adddesc','$addamen','$addact','$addrates','$filename','$filenametwo')";

    $Rs = mysql_query($query, $localhost) or die(mysql_error());

     

     

    Header ('Location:index.php');

     

    }

    ?>

     

  6. yeah I know you can do it with javascript I just wanted to see if you could do it by somehow saving there entry in the first field into the session. right now, with $_SESSION['region']='North America' it shows only the countries in North America, so if I could somehow change North America to just be whatever they selected in the option w/ echo $row_Rs['region']; I would be good. So I need to store what they select, hopefully in that session tag, and apply that to the field below.

  7. I have a form that has two dropdown boxes. The options of each dropdown box are read from a different field in a table of a database. The first box is for Regions, the second for Countries. Using sessions, I would like to make it so that when you select the first box, the second one is updated to the countries listed in the region that was selected. I can make it so that the first box lists all regions and the second lists all countries, but I only want the second to list countries that are in the selected region. here is my code, pay attention to the bold part as I need to change  $_SESSION['region']='North America' to  $_SESSION['region']='whatevertheuserjustselected' - is there anyway to do this?

     

    <form name="form1" method="post" enctype="multipart/form-data" action="addstate.php">

            <table width="100%" border="0" cellspacing="1" cellpadding="0">

            <tr>

                <td class="text2">Select Region</td>

                <td> 

              <?

     

     

    mysql_select_db($database_localhost, $localhost);

    $query_Rs = "SELECT * FROM countries";

    $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error());

    $totalRows_Rs = mysql_num_rows($Rs);

     

    ?>

                  <select name="region" class="text2" id="region">

                    <? while ($row_Rs = mysql_fetch_assoc($Rs))

      {

      ?>

                    <option value="<? echo $row_Rs['region']; ?>"><? echo $row_Rs['region']; $_SESSION['region']='North America'  ?></option>

                  <? } ?>

                  </select>

             

              <?

    $region=$_SESSION['region'];

    $query_Rs = "SELECT * FROM countries where region='$region'";

    $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error());

    $totalRows_Rs = mysql_num_rows($Rs);

     

    ?>

                  <select name="region2" class="text2" id="region2">

                    <? while ($row_Rs = mysql_fetch_assoc($Rs))

      {

      ?>

                    <option value="<? echo $row_Rs['countryid'];?>"><? echo $row_Rs['countryname'];?></option>

                   

                  <? } ?>

             

                  </select>

                 

              </td></tr> <tr>

                <td class="text2">State Name</td>

                <td><input name="statename" type="text" class="text2" id="statename"></td>

     

         

                <td><input name="Submit" type="submit" class="text2" value="Add State"></td>

              </tr>

            </table>

          </form>

  8. Yes, you are right. Can you help me wrap this up? I got this far, the bold is what I need to change:

     

    <form name="FormSubmit" action="">

        <?

    mysql_select_db($database_localhost, $localhost);

    $query_Rs = "SELECT * FROM regions";

    $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error());

    $totalRows_Rs = mysql_num_rows($Rs);

     

    ?>

    <select NAME="SELECT1" ID="SELECT1"

    onChange="subselect(this.options.selectedIndex)" ="combobox">

    <? while ($row_Rs = mysql_fetch_assoc($Rs))

      {

      ?>

     

     

     

    <option value="<? echo $row_Rs['regionid'];?>"><? echo $row_Rs['regionname'];  ?></option><? } ?>

    </select>

    <?

    mysql_select_db($database_localhost, $localhost);

    $query_Rs = "SELECT * FROM countries";

    $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error());

    $totalRows_Rs = mysql_num_rows($Rs);

     

    ?>

    <select NAME="SELECT2" ID="SELECT2" class="combobox">

    <option value="" selected>-</option>

    </select>

    <input type="submit" name="submit">

     

    <script>

    <!--

    var groups=document.FormSubmit.SELECT1.options.length

    var group=new Array(groups)

    for (i=0; i<groups; i++)

    group=new Array()

     

    group[0][1]=new Option("option1")

    group[0][2]=new Option("option2")

     

    group[1][0]=new Option("all ")

    group[1][1]=new Option("sub1-1","1")

    group[1][2]=new Option("sub1-2","2")

    group[2][0]=new Option("- all - ")

    group[2][1]=new Option("sub2-1","3")

    group[2][2]=new Option("sub2-2","4")

     

    var temp=document.FormSubmit.SELECT2

     

    function subselect(x){

    for (i=temp.options.length-1;i>0;i--)

      temp.options=null

    for (k=0;k<group[x].length;k++){

      temp.options[k]=new Option(group[x][k].text,group[x][k].value)

    }

    temp.options[0].selected=true

    }

    //-->

    </script>

    </form>

  9. Let me clarify:

    I am talking about one form with two drop down boxes, the first selecting a region from the region table and the second selecting a country from the country table where the region equals the region selected in the first box. I can get the first box to display all data by simply selecting it from the region table by regionname. The second box I can get to show all countries, but I can't get it to show only countries w/ the selected region.

  10. In this example, what would $country be equal to? Is my problem that the first field is being selected from one table and the second field is being selected from another?

     

    Posts: 1,196

     

    Call me Ben

     

    smithers.ben@googlemail.com

    View Profile

     

     

    Re: HELP!!! w/ displaying certain items from databases

    « Reply #3 on: Today at 12:28:58 PM »

    Reply with quoteQuote

    As was said, you only select those states from the database which are from the previously selected country. That is the idea of the where clause in this statement:

     

    Code:

     

    $sql = "SELECT * FROM some_table WHERE country = '$country'";

  11. So if I create two databases, one called Countries and the other called States, and countries has two fields called United States and Mexico and states has one state in each country, how do I create a page that only displays the states in a certain country? For example, a user will select a country that he wants and be brought to a page where he will select a state, but with my experience it always shows all of the states from both countries. I know that I could make an individual page for each country and do select from * countries where state='North America' but there are going to be far too many countries, states, and cities to do this over and over again. Any suggestions?

     

    Also, when users add a country or state, they select the country and then they select the state, but right now it shows all states and not just the states within a country. These selections are made from drop down field boxes. Note that when you add a state it records in the state table which country the state is in.  For the field boxes for adding a state (where you select region, which should show all regions, and then you select countries, which should show the countries in a region) this is the code I have:

     

     

     

    <form name="form1" method="post" enctype="multipart/form-data" action="addstate.php">

            <table width="100%" border="0" cellspacing="1" cellpadding="0">

            <tr>

                <td class="text2">Select Region</td>

                <td> 

              <?

    mysql_select_db($database_localhost, $localhost);

    $query_Rs = "SELECT * FROM regions";

    $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error());

    $totalRows_Rs = mysql_num_rows($Rs);

     

    ?>

                  <select name="region1" class="text2" id="region1">

                    <? while ($row_Rs = mysql_fetch_assoc($Rs))

      {

      ?>

                    <option value="<? echo $row_Rs['regionid'];?>"><? echo $row_Rs['regionname'];?></option>

                    <? } ?>

                  </select>

             

              </td></tr> <tr>

                <td class="text2">Select Country</td>

                <td> 

              <?

     

    mysql_select_db($database_localhost, $localhost);

    $query_Rs = "SELECT * FROM countries";

    $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error());

    $totalRows_Rs = mysql_num_rows($Rs);

     

    ?>

                  <select name="country" class="text2" id="country">

                    <? while ($row_Rs = mysql_fetch_assoc($Rs))

      {

      ?>

                    <option value="<? echo $row_Rs['countryname'];?>"><? echo $row_Rs['countryname'];?></option>

                    <? } ?>

                  </select>

              </td></tr> <tr>

                <td class="text2">State Name</td>

                <td><input name="statename" type="text" class="text2" id="statename"></td>

         

             

             

           

           

             

                <td><input name="Submit" type="submit" class="text2" value="Add State"></td>

              </tr>

            </table>

          </form>

  12. i am trying to make it so that i can upload an image and a title for the image and they will automatically be displayed on a page that will look like this:

     

    Image1

    Title1

     

    Image 2

    Title 2

     

    Image 3

    Title 3

     

    etc.

     

    Right now I have it so that I upload the title to a database and the image to a folder and I can make it so that the page shows one image and one title but I do not know how to show all images with the appropriate title below each one. help please?

     

    this is the code I have that will display one image and title, but when more than one is uploaded it does not work:

     

    <img src="featuredimages/<? mysql_select_db($database_localhost, $localhost);

    $query_Rs = "SELECT * FROM featuredprop order by featurename";

    $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error());

    $totalRows_Rs = mysql_num_rows($Rs);

    $OrFileName = $row_Rs['featuredprop'];

    while ($row_Rs = mysql_fetch_assoc($Rs))echo $row_Rs['featurename'];?>" height="100" width="100" >

    </div>

                  <? mysql_select_db($database_localhost, $localhost);

    $query_Rs = "SELECT * FROM featuredprop order by featuredtitle";

    $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error());

    $totalRows_Rs = mysql_num_rows($Rs);

    $OrFileName = $row_Rs['featuredprop'];

    while ($row_Rs = mysql_fetch_assoc($Rs))echo $row_Rs['featuredtitle'];?>

  13. Hey I am not looking to link to each file individually, that would be too easy, I am looking to make it so that when I upload a file the new image and titled is placed below the previous image/title.

  14. so I have this script, it uploads images to a folder and a title for the image to a database and I want to have a page that lists all Image w/ image title under it in a vertical row. It will looks like:

     

    Image

    "title"

     

    Image

    "title"

     

    I made the page and when there is only one image/title it looks fine but when i try to add more than one it does not work out right. in other words i need to add a space between each image and title.

     

    this is the relevant code that i have. the first part gets the image and the second gets the title:

     

     

    <img src="featuredimages/<? mysql_select_db($database_localhost, $localhost);

    $query_Rs = "SELECT * FROM featuredprop order by featurename";

    $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error());

    $totalRows_Rs = mysql_num_rows($Rs);

    $OrFileName = $row_Rs['featuredprop'];

    while ($row_Rs = mysql_fetch_assoc($Rs))echo $row_Rs['featurename'];?>" height="100" width="100" > <br></div>

    <? mysql_select_db($database_localhost, $localhost);

    $query_Rs = "SELECT * FROM featuredprop order by featuredtitle";

    $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error());

    $totalRows_Rs = mysql_num_rows($Rs);

    $OrFileName = $row_Rs['featuredprop'];

    while ($row_Rs = mysql_fetch_assoc($Rs))echo $row_Rs['featuredtitle'];?>

     

     

    can anyone help?

×
×
  • 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.