Jump to content

Julian

Members
  • Posts

    148
  • Joined

  • Last visited

    Never

Everything posted by Julian

  1. Hello guys I'm getting the results from my database using do {} while, this is working fine. What I want to is put a number starting from 1 to each result, each record has it's unique key but I want to start from 1 with the results, example: do { echo "Number # Here" . $row_name['name'] . "<br />"; } while ($row_name = mysql_fetch_assoc($name)); Output "Number 1 Here" John "Number 2 Here" Teresa "Number 3 Here" Jamie
  2. Is not PHP is simple HTML code: <a name="ANCHOR_NAME" id="ANCHOR_NAME"></a> Just place the anchor where you want the page to land after submission.
  3. You can try with anchors
  4. It not inserting the data, and yes I'm obtaining a variable with $news
  5. I did that using js, try this code: script language="JavaScript" type="text/javascript"> <!-- function getsupport ( selectedtype ) { document.YOUR_FORM_NAME.supporttype.value = selectedtype ; document. YOUR_FORM_NAME.submit() ; } --> </script> <a href="javascript:getsupport('pass')">View popular categories</a> <input type="hidden" name="supporttype"/>
  6. Hello! I have this code to upload files, and I want to store the file names into the database, so far I have: $news = ($HTTP_GET_VARS['id_noticia']); foreach ($_FILES as $fieldName => $file) { move_uploaded_file($file['tmp_name'], "../../images/documentos/" . $file['name']); mysql_select_db($database_rcpc, $rcpc); $updateSQL = "INSERT INTO documentos (id_noticia, nombre) VALUES (".$news.",".$file['name'].")"; $update = mysql_query($updateSQL); } Files upload fine. Script to connect to db is fine also, but for some reason is not inserting... any hint? Thanks
  7. Have you tried using: SELECT DISTINCT or GROUP BY?
  8. Hi guys... Have this code: <?php error_reporting(0); define ( 'FILE_UPLOAD_DIR', '/path_to/documentos/' ); $fileObject = $_FILES ['Filedata']; $fileSize = ( double ) $fileObject ['size']; $fileName = $fileObject ['name']; $fileType = strtolower ( pathinfo ( $fileName, PATHINFO_EXTENSION ) ); $fileTempPath = $fileObject ['tmp_name']; $fileUploadPath = rtrim ( FILE_UPLOAD_DIR, '/' ) . '/' . basename ( $fileName ); if (move_uploaded_file ( $fileTempPath, $fileUploadPath )) { echo "OK"; } else { die ( "Ocurrió un error al intentar cargar el archivo" ); } ?> It works with a flash uploader that waits until the "OK" to finish. After it finishes I need to continue with mysql inserts. The code works, but it doesn't finish because the other part of the code is executing. How can I make the other part of the code wait until the first part finishes? Here's the other part of the code: if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE noticias SET tipo=%s, titulo=%s, id_miembro=%s, dia=%s, mes=%s, ano=%s, status=%s, bajada=%s, principal=%s, secundario=%s, comentarios=%s, pie1=%s, pie2=%s, pie3=%s, video1=%s, pie4=%s, video2=%s, pie5=%s, audio1=%s, pie6=%s, audio2=%s, pie7=%s, documento=%s, tags=%s, title_eng=%s, keywords=%s, description=%s, belice=%s, costarica=%s, elsalvador=%s, guatemala=%s, honduras=%s, nicaragua=%s, panama=%s WHERE id_noticia=%s", GetSQLValueString($_POST['tipo'], "int"), GetSQLValueString($_POST['titulo'], "text"), GetSQLValueString($_POST['id_miembro'], "int"), GetSQLValueString($_POST['dia'], "int"), GetSQLValueString($_POST['mes'], "text"), GetSQLValueString($_POST['ano'], "int"), GetSQLValueString(isset($_POST['status']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['bajada'], "text"), GetSQLValueString($_POST['principal'], "text"), GetSQLValueString($_POST['secundario'], "text"), GetSQLValueString(isset($_POST['comentarios']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['pie1'], "text"), GetSQLValueString($_POST['pie2'], "text"), GetSQLValueString($_POST['pie3'], "text"), GetSQLValueString($file_new_name1, "text"), GetSQLValueString($_POST['pie4'], "text"), GetSQLValueString($file_new_name2, "text"), GetSQLValueString($_POST['pie5'], "text"), GetSQLValueString($file_new_name3, "text"), GetSQLValueString($_POST['pie6'], "text"), GetSQLValueString($file_new_name4, "text"), GetSQLValueString($_POST['pie7'], "text"), GetSQLValueString($file_new_name5, "text"), GetSQLValueString($_POST['tags'], "text"), GetSQLValueString($_POST['title_eng'], "text"), GetSQLValueString($_POST['keywords'], "text"), GetSQLValueString($_POST['description'], "text"), GetSQLValueString(isset($_POST['belice']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['costarica']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['elsalvador']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['guatemala']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['honduras']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['nicaragua']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['panama']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['id_noticia'], "int")); mysql_select_db($database_rcpc, $rcpc); $Result1 = mysql_query($updateSQL, $rcpc) or die(mysql_error()); $updateGoTo = "list.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); }
  9. Hi guys... Have this code: <?php error_reporting(0); define ( 'FILE_UPLOAD_DIR', '/path_to/documentos/' ); $fileObject = $_FILES ['Filedata']; $fileSize = ( double ) $fileObject ['size']; $fileName = $fileObject ['name']; $fileType = strtolower ( pathinfo ( $fileName, PATHINFO_EXTENSION ) ); $fileTempPath = $fileObject ['tmp_name']; $fileUploadPath = rtrim ( FILE_UPLOAD_DIR, '/' ) . '/' . basename ( $fileName ); if (move_uploaded_file ( $fileTempPath, $fileUploadPath )) { echo "OK"; } else { die ( "Ocurrió un error al intentar cargar el archivo" ); } ?> It works with a flash uploader that waits until the "OK" to finish. After it finishes I need to continue with mysql inserts. The code works, but it doesn't finish because the other part of the code is executing. How can I make the other part of the code wait until the first part finishes? Here's the other part of the code: if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE noticias SET tipo=%s, titulo=%s, id_miembro=%s, dia=%s, mes=%s, ano=%s, status=%s, bajada=%s, principal=%s, secundario=%s, comentarios=%s, pie1=%s, pie2=%s, pie3=%s, video1=%s, pie4=%s, video2=%s, pie5=%s, audio1=%s, pie6=%s, audio2=%s, pie7=%s, documento=%s, tags=%s, title_eng=%s, keywords=%s, description=%s, belice=%s, costarica=%s, elsalvador=%s, guatemala=%s, honduras=%s, nicaragua=%s, panama=%s WHERE id_noticia=%s", GetSQLValueString($_POST['tipo'], "int"), GetSQLValueString($_POST['titulo'], "text"), GetSQLValueString($_POST['id_miembro'], "int"), GetSQLValueString($_POST['dia'], "int"), GetSQLValueString($_POST['mes'], "text"), GetSQLValueString($_POST['ano'], "int"), GetSQLValueString(isset($_POST['status']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['bajada'], "text"), GetSQLValueString($_POST['principal'], "text"), GetSQLValueString($_POST['secundario'], "text"), GetSQLValueString(isset($_POST['comentarios']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['pie1'], "text"), GetSQLValueString($_POST['pie2'], "text"), GetSQLValueString($_POST['pie3'], "text"), GetSQLValueString($file_new_name1, "text"), GetSQLValueString($_POST['pie4'], "text"), GetSQLValueString($file_new_name2, "text"), GetSQLValueString($_POST['pie5'], "text"), GetSQLValueString($file_new_name3, "text"), GetSQLValueString($_POST['pie6'], "text"), GetSQLValueString($file_new_name4, "text"), GetSQLValueString($_POST['pie7'], "text"), GetSQLValueString($file_new_name5, "text"), GetSQLValueString($_POST['tags'], "text"), GetSQLValueString($_POST['title_eng'], "text"), GetSQLValueString($_POST['keywords'], "text"), GetSQLValueString($_POST['description'], "text"), GetSQLValueString(isset($_POST['belice']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['costarica']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['elsalvador']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['guatemala']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['honduras']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['nicaragua']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['panama']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['id_noticia'], "int")); mysql_select_db($database_rcpc, $rcpc); $Result1 = mysql_query($updateSQL, $rcpc) or die(mysql_error()); $updateGoTo = "list.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); }
  10. Are `month` and `year` separate columns on your sql structure? or are you using a date column that contains the month and year?
  11. Hello, I have this script from DW thats puts into tabs the contents. I'm getting the "Tab" and "Content" from database, but I'm having issues with the loop. I hope someone here can help me out... I'll comment my problems on the script: <div id="TabbedPanels1" class="TabbedPanels"> <ul class="TabbedPanelsTabGroup"> <li class="TabbedPanelsTab" tabindex="0">Tab 1</li> //Here's the first loop <li class="TabbedPanelsTab" tabindex="0">Tab 2</li> </ul> <div class="TabbedPanelsContentGroup"> <div class="TabbedPanelsContent">Content 1</div> // Here's the second loop <div class="TabbedPanelsContent">Content 2</div> </div> </div> And here's the tricky part: First loop depends on the result of the second loop.... database query: mysql_select_db($database_rcpc, $rcpc); $query_new = "SELECT noticias.id_noticia AS id_noticia, paises.pais AS pais, noticias.tipo AS tipo, noticias.titulo AS titulo, noticias.status AS status, noticias.bajada AS bajada "; $query_new .= "FROM noticias "; $query_new .= "INNER JOIN paises ON noticias.id_pais=paises.id_pais "; $query_new .= "WHERE tipo = 2 AND noticias.status = 1 "; $query_new .= "ORDER BY paises.orden ASC, id_noticia DESC"; $new = mysql_query($query_new, $rcpc) or die(mysql_error()); $row_new = mysql_fetch_assoc($new); $totalRows_new = mysql_num_rows($new); Thanks for looking!
  12. Never mind.... I have to trim white space!!! It works now. Thank you very much!!!
  13. Thanks Keith I got rid the error message, working now. Test the script but I found that the results are not as expected. Practical example: On record 1, I have tags: "test, prueba, example". On record 2, I have tags: "test" When display record 2, results are as expected. query shows anything related to "test". On the other hand record 1 only show itself. Thanks again...
  14. Hello, I'm I'm dealing with a simple tags search on my website. Each tag is stored separated by a comma in the same column. (pool, ball, dinner) I'm working with this script that actually do the trick, but I'm facing a MySQL error: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tags LIKE '%test%' ORDER BY fecha ASC' at line 1" Here's the code: $q = $row_noticias['tags']; //bit of sanitizing $qtrim = strtolower($q); $qtrim = stripslashes($q); $qtrim = strip_tags($q); $qtrim = trim($q); //split values by whitespace into an array, then for each array member stick them together with "OR columnname LIKE '%$arrayvalue%' " $qtrim = explode(',', $q); foreach($qtrim as $value) { $qtrim = $qtrim."OR tags LIKE '%".$value."%' "; } //we now have a string which has the following value: //OR fullname LIKE '%".$value1."%' OR fullname LIKE '%".$value2."%' //we now need to remove the first OR, so the string looks like this: //fullname LIKE '%".$value1."%' OR fullname LIKE '%".$value2."%' $qtrim = substr($qtrim,2); //then we use the string in a mysql query //$query = "SELECT * FROM products WHERE ".$qtrim; $query_relacionados = "SELECT * FROM noticias WHERE " .$qtrim. " ORDER BY fecha ASC"; $relacionados = mysql_query($query_relacionados, $rcpc) or die(mysql_error()); Thanks for your help!!!!
  15. This is driving me nuts... any hint... please
  16. Hello! Sorry for open this post. But I have the same situation. only the last record is selected. Does anyboby know how to solve it? Regards
  17. Maybe I explained myself the wrong way. I don't care about the the random image. I need to populate the array with mysql results in this format: $banner = array ( result1, result2, result3, etc ); thanks
  18. Anyone? In short words i'm trying to fill the array with mysql results. The problem here is to loop with the array format in order to work with the rest of the script. Thanks
  19. // an array of banners $banners = array ( '<a href="http://www.costaricamd.net/admin/ccount/click.php?id=' . $row_banner4['link'] . '" target="_blank"><img src="/images/banners/' . $row_banner4['banner1'] .'" alt="' . $row_banner4['cliente'] . '" border="0" /></a>' ); Thanks for looking. How can I loop all the results inside the $banners = array(.... The code above only shows the first record on the database. I need to loop for all the records and put them in that format. Like $banners = array( foreach... Thanks again
  20. Hello gurus! Maybe someone here can help me. I'm making a rotating banner system. I found this excellent script and it works perfectly. Here's my situation. I want retrieve from the database all the banners and rotate them using this script. But as you can see I have to store the results on an array(); I really need a lead on how to do that in the script format: Here we go: <?php require_once('../../admin/Connections/red.php'); mysql_select_db($database_red, $red); $query_banner4 = "SELECT * FROM banners WHERE status = 1 AND position = 4 AND CURDATE() < termino"; $banner4 = mysql_query($query_banner4, $red) or die(mysql_error()); $row_banner4 = mysql_fetch_assoc($banner4); $totalRows_banner4 = mysql_num_rows($banner4); // an array of banners $banners = array ( '<a href="http://www.mysite..com/click.php?id=' . $row_banner4['link'] . '" target="_blank"><img src="/images/banners/' . $row_banner4['banner1'] .'" alt="' . $row_banner4['cliente'] . '" border="0" /></a>' ); // pick a random one $html = $banners[array_rand($banners)]; // send XML headers header('Content-type: text/xml'); echo '<?xml version="1.0" ?>'; // print the XML response ?> <banner> <content><?php echo htmlentities($html); ?></content> <reload>5000</reload> </banner> On $banners I have to loop for the records (maybe while or foreach) but I don't know how to put the result in the right format. On the script it works fine but is not looping, only get the first record. Thanks in advance!
  21. Thanks for the help. But it is not that simple. I'm comparing two tables, the common field is "id_especialidad". As I wrote, I almost achieved that but I need to loop in order to "check" the values.
  22. Hi guys. I have almost everything done with this script. What it does is show me checkboxes with text. I achieved this with the following code: <?php //get the number of rows in our result so we can use it in a for loop $numrows = (mysql_num_rows ($es)); // loop to create rows if($numrows >0){ echo "<table width ='100%' border = '0' cellspacing = '5' cellpadding = '0'>"; // loop to create columns $position = 1; while ($work = mysql_fetch_array($es)){ if($position == 1){echo "<tr>";} echo "<td width='18' valign='top'><input type='checkbox' id='espe' name='id_especialidad[]' value=''"; if (!(strcmp($work['id_especialidad'],$row_espe['id_especialidad']))) {echo "checked";} //Loop here echo "></td>"; echo "<td class='class10'>" . $work['especialidad'] . "</td> "; if($position == 4){ echo "</tr> "; $position = 1;}else{ $position++;} } $end = ""; if($position != 1){ for($z=(4-$position); $z>0 ; $z--){ $end .= "<td></td>"; } $end .= "</tr>"; } echo $end."</table> "; } ?> I need to compare to tables to put "checked" where the user already checked the box. But I can show only the first record on the database checked. I think I need to loop to compare buy don't know how. Any help will be appreciated.
×
×
  • 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.