Jump to content

siric

Members
  • Posts

    116
  • Joined

  • Last visited

Posts posted by siric

  1. Try this.  As I do not have your CSS file, I cannot get the styling exact, but you should be able to get through that.  Also, define all of your classes in the CSS file and replace

     

    <p align="left" style="margin-top: -1; margin-bottom: -1">
    

     

    with

     

    <p class="whatever">
    

     

     

    //CSS file
    
    .whatever {
    text-align= left;
    margin-top: -1;
    margin-bottom: -1
    }
    

     

     

    This will make your code easier to read and the formatting easier to change when ever you need to.

     

     

    <body>
    	<?php
    	 	if(!isset($_POST['submit'])){
    	?>
    
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    	<p align="left" style="margin-top: -1; margin-bottom: -1">
    	<span class="style2"><b><font size="2">Search by Zip:</font></b>
        <input type="text" name="zipCode" size="20"> 
    	<b><font size="2">(example: 01922)  </font></b></span></p>
        <p align="left" style="margin-top: -1; margin-bottom: -1">
        <span style="font-family: Arial, Helvetica, sans-serif"><br>
        <font size="2"><b>Search by State:     </b></font> 
    	<input type="text" name="state" size="20">
    	<b> <font size="2">(example: NY for New York) </font></b></span>
    	<input type="submit" name="submit" value="Go">
    </form> 
    
    	<?php 
    		} else {
    		// Page two, search and display 
    $connect = mysql_connect("localhost", "root", "sysadmin");  
    $db = mysql_select_db("test", $connect);  
    
    $sql = "SELECT * FROM STOREDATA WHERE State = '".$_POST['state']."' OR ZIP_Code = '".$_POST['zipCode']."'";  
    
    $result = mysql_query($sql);  
    $rows = mysql_num_rows($result);  
    if($rows > 0) {  
    	  echo "<p><center></p>
    			<table border=\"1\">  
    			<th align=\"center\newstyle\">Name</th> 
    			<th align=\"center\">City</th> 
    			<th align=\"center\">State</th> 
    			<th align=\"center\">Sales Phone</th>"; 
    
    	while($row=mysql_fetch_array($result)) {  
    		echo "<tr><center>
    				<td align=\"center\" class=\"newstyle\">".$row['Name']."</td>
    				<td align=\"center\" class=\"newstyle\">".$row['City']."</td>
    				<td align=\"center\" class=\"newstyle\">".$row['State']."</td>
    				<td align=\"center\" class=\"newstyle\">".$row['Sales_Phone']."</td>
    			  </tr>";  
    	}  
    }  
    else {  
    	echo "No results found";  
    }  
    mysql_close($connect); ;
    		}
    	?>
    </body>
    

  2. Very possible.

     

     

     

    if (isset(submit)) {  //This checks to see if the submit button is set
    
    //process query
    
    } else {
    
    //Show form  .......
    <FORM name="search"  action="<?php echo $_SERVER['PHP_SELF']; ?> "  method="post" >  //This calls itself when the submit if clicked.
    
    ...........
    
    

     

     

    }

  3. There is no need to js.  In the <form> line use

     

    <FORM name="feature" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
    

     

    This will cause the page to reload itself.

     

    Also where do you load the variables user->credits which is used in this line ?

     

      if($user->credits < '1000') {
    

  4. Tested this and it works.

     

     

    
    <script type='text/javascript'>
      function disp_confirm(companyid) {
        var c = confirm('Do you really want to archive this company?');
    if (c == true)  {
        window.location.href  = 'companies.php?action=Archive&companyid='+companyid;
    }
      }
    </script>
    
    
    
    
    <?
    $companyid = '1';
    echo "<input type='image'  src='blue.png'   onclick=\"disp_confirm('$companyid')\" />";
    ?>
    
    

     

     

  5. Ok,

     

    Have done some further research and have come up with this so far.  The main problem seems to be the image for the form button.  If you do not use an image and use window.location, it works.

     

    function disp_confirm(companyid) {
    var c = confirm('Do you really want to archive this company?');
          
          if (c == true)  {
                var link='companies.php?action=Archive&companyid='+companyid;
                window.location=link;
    
              //could also be
              // window.location = 'companies.php?action=Archive&companyid='+companyid;
    
          }
    
    }
    

     

    and html

     

    echo "<input type='button' value='Redirect' onclick=\"disp_confirm('$companyid')\">";
    

     

     

    Will chk further on the image as button option.

  6. I moved around the code a bit as

     

    function disp_confirm(companyid) {
          var c = confirm('Do you really want to archive this company?');
          
          if (c == true)  {
                var link='companies.php?action=Archive&companyid='+companyid;
                alert(link);
          }
    } 
    
    

     

    The alert shows that the correct url is passed to link variable.  It would be just a matter of getting that into the URL.

  7. You need to find out how many rows the query has returned and then loop through the results.

     

     

    Pseudo Code

    
    $number_of_rows = mysql_num_rows($sql_eventos)  //Get number of rows returned 
    
    <select>
    
    for ($count=0; $count< $number_of_rows; $count++) {
           <option value........>
    }
    
    </select>
    

  8. Break down

     

    $query = sprintf ("INSERT INTO album (date, name, desc) VALUES ('$date', '$name', '$desc')");
        $result = mysql_query ($query);  //  Her stopper det tipper jeg
    

     

    to

     

    $query = "INSERT INTO album (date, name, desc) VALUES ('$date', '$name', '$desc')";
    
    print $query;
    
    $result = mysql_query ($query);  //  Her stopper det tipper jeg
    

     

    This will allow you to look at the query statement to ensure that it is correct and to run it directly against the database.  Also, why are you using sprintf ?

  9. Ok,

     

    Went through it in detail and this works.  Don't even need arrays - my bad.

     

    
    $max_number_of_cats = 10;
    
    for ($count = 1; $count < $max_number_of_cats+1; $count++) {  //start number for count is the first cat number
    
        $sql = "SELECT * FROM photo WHERE photo_category='$count' ORDER BY photo_id DESC";
        $result= mysql_query($sql);
    $num_rows = mysql_num_rows($result);
        	
    	if ($num_rows > 0) {   //If there is a result for the cat search, then display the divs
    	//Start div here
    
    	for ($i=0; $i<$num_rows;$i++) {
    		$photo_id=mysql_result($result, $i, "photo_id");
    		$photo_caption=mysql_result($result, $i, "photo_caption");
    		$photo_filename=mysql_result($result, $i, "photo_filename");
    		$photo_category=mysql_result($result, $i, "photo_category");
    		$photo_colour=mysql_result($result, $i, "photo_colour");
    
    		print "Photo - $photo_id - $photo_caption - $photo_filename - $photo_color - $photo_category<br/>";
             
    	}
    print "Cat Change<br/><br/>";  //end your div here
    }
    }
    
    

     

    Try that and let me me know.

  10. You would need to use an array for the categories.

     

    Find out how many categories you have and define an array -

     

    $cat = array();
    
    for ($count = 1; $count < $max_number_of_cats+1; $count++) {
    
          $result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM art_photos WHERE photo_category='".addslashes($cat[$count])."' ORDER BY photo_id DESC" );
          //cat[$count] here would equate to cat1 in the first instance, cat2, etc.
    
    
    
          if ($result) {   //If there is a result for the cat search, then display the divs
              ...
               //make div and display
             ...
         }
    }
    
    

     

     

  11. Whenever I get into problems with variables, I just validate them by assigning $_POST variables to a normal var and printing them.

     

    So as Muddy_Funster has suggested, assign the POST to $date and do a print afterwards to ensure that it is correct.

     

    Also, note that your entry field allows free text, so unless you are using this yourself, it can lead to problems, as users can enter the date in any format.

     

     

  12. I am probably WAY off mark here, but wouldnt this also work?

      $file_name = $file_name_array['0'];
      $new_name = str_replace($substr($file_name, -3, 3), 'flv', $file_name);
    

     

    You do not even have to place the name in an array to do it this way.

     

    Simply

    $file_name = 'myvideo.avi';
    $new_name = str_replace(substr($file_name, -3, 3), 'flv', $file_name);
    

     

    That would work.  The limitation here is that it will only work with file extensions of 3 characters in length.  And remember, no $ in front of the substr function name.

  13. Works for me.  What I would do however is to use the same name for the submit button, but only change the value

     

    <input type="submit" name="submit" id="tilbake" value="Back" />
    <input type="submit" name="submit" id="lagre" value="Finished" />
    <input type="submit" name="submit" id="publiser" value="Publish" />
    

     

    Then in the preview.php

     

    $selection = $_POST['submit'];
    
    if ($selection == 'Back') {
    
    ...
    
    } elseif ($selection == 'Finished') {
    
    .....
    
    } elseif ($selection == 'Publish') {
    
    ......
    
    }
    
    

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