Jump to content

johanlundin88

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

johanlundin88's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ok, but I still don't know how to do it.. Something like this? if (empty($_POST['namn'])) { What should I write here? }
  2. This shange closes the whole script? I still want to run the search, but without the empty searchstring. I dont want to serch in 'namn' if that search string is empty, but I still want to search in 'id' and 'status'.
  3. I'm trying to make a search script. I don't want the script to search for empty values if you don't write anything in one of the searchfields. Does anyone know how to do this, or where I can find examples of advanced searchscripts? This is the script so far: <form method="post" action="sok.php"> Namn:<br> <input name="namn" type="text"><br> ID:<br> <input name="id" type="text"><br> Status:<br> <select name="status"> <option value="">«Ange status»</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <br><br> <input type="submit" value="Sök"> </form> <?php // hämtar information från den angivna tabellen $result = mysql_query("SELECT * FROM personer WHERE id='$_POST[id]' OR namn LIKE '$_POST[namn]' OR status='$_POST[status]'") or die(mysql_error()); if(isset($_POST['namn'])) { //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($result); if ($anymatches == 0) { echo "<br>Tyvärr, kunde vi inte hitta något. Testa söka på något annat.<br><br> "; } else { echo "<br><b>Reslutat: $anymatches</b> "; } // HTML-tabellens formatering - tabellstart echo "<br><table border='1' cellspacing='0' cellpadding='3'>"; // hämtar resultatrader från tabellen while($row = mysql_fetch_array( $result )) { // skriver ut innehållet i raderna till HTML-tabellen echo "<tr><td>"; echo $row['id']; echo "</td><td>"; echo "<span class=\"namn\"><a href='http://www" . $row['id'] . "'>".$row["namn"]."</a></span>"; echo "</td><td>"; echo $row['status']; echo "</td></tr>"; } // HTML-tabellens formatering - tabellslut echo "</table>"; // stänger databasen mysql_close($opendb); } ?>
  4. I got this to work now, thanks for the help: $filename = '../pictures/' . $rad['id'] . '.jpg'; if (file_exists($filename)) { echo '<img src="'.$filename.'" alt="' . $rad['namn'] . ' Foto: ' . $rad['fornamn'] . ' ' . $rad['efternamn'] . ', " width=80 height=100 border=0 /><br>' . $rad['namn'] . ' '; } else { echo ' No picture '; }
  5. That doesn't make any difference, it's still the same. The no-picture thing and the picture doesn't seam to work at the same time but both of them works separate..
  6. There is no error message, the "no picture"-thing just doesn´t show up. The "no picture"-thing works (but on all pictures) if I shange: if (count($pictures) > 0) { to: if (count($pictures) > 1) { How do I use if(file_exists("filename")){
  7. I want this script to get the pictures with the id of persons in a database, this works. But when there are no picture with correct id in the folder I want the script to show a "No picture"-picture, but this doesn´t work with this script. Why not? <?php $hamta = "SELECT * FROM persons ORDER BY name"; $resultat = mysql_query($hamta) or die("Error!"); while($rad = mysql_fetch_array($resultat)) { $pictures = glob('pictures/' . $rad['id'] . '.jpg'); if (count($pictures) > 0) { foreach($pictures as $picture) { echo '<img src="', $picture, '" alt="" />'; } } else { echo '<img src="pictures/no_picture_.jpg" alt="No picture" />'; } } mysql_free_result($resultat); ?>
  8. I want a script that makes it possible to upload an original-sized image and from this image crop out 3 different formats when these 3 are cropped out I want them to resize into right size, change name by id and upload to my server. Information about the images should be sent to a database. I found this script that maybe could help me with the cropping: [a href=\"http://tech.tailoredweb.com/image-editor-52.php?forum=imageeditor&page=3\" target=\"_blank\"]http://tech.tailoredweb.com/image-editor-5...geeditor&page=3[/a] I’m quite new at PHP, any ideas?
×
×
  • 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.