Jump to content

digitalgod

Members
  • Posts

    374
  • Joined

  • Last visited

    Never

Everything posted by digitalgod

  1. because most of everything is stored in sessions and if for some reason I decide to rename the session variable,  Iwon't have to rename it everywhere
  2. hey Ken, that worked perfectly thank you. If I use arrays in the form how do I process them? this is what I got in my admin.php [code] for ($i = 1;$i <= $num_news;$i++) {                            $headline = $i;                             $content = $_POST['news_content' . $i];                             $type = $_POST['type' . $i]; mysql_query("UPDATE " . $prefix . "news SET content='$content',type='$type' WHERE headline='$headline' AND date='$date'") or die(query_error());                         } [/code] but it doesn't seem to update anything, it doesn't give me an error either. I think it has to do with $num_news. In the form $num_news is greater than 1. but when I echo $num_news right before the loop it doesn't output anything. this is what defines $num_news [code] if ($_POST['date'] != '') { $_SESSION['news_date'] = $_POST['date'];  //gets it from the first form $date = $_SESSION['news_date']; $result = mysql_query("SELECT COUNT(*) AS count FROM " . $prefix . "news WHERE date='$date'"); $_SESSION['num_news'] = mysql_result($result,0,'count'); $num_news = $_SESSION['num_news']; echo $num_news; //works perfectly here                                                        } [/code] And yes I did notice that it will output $row['content'] n times, I'm really not sure how to get the correct info from the DB. Let's say I have 3 entries that have the same date but different content, I want to be able to display that content in different textboxes
  3. I just re-did that and got nothing :P *edit* here's the full code [code] <?php $num_news = $_SESSION['num_news']; $date = $_SESSION['news_date']; $result=mysql_query("SELECT * FROM news WHERE date='". $date ."'") or die(query_error()); $row=mysql_fetch_array($result); echo $row['content']; ?> <div id="article"> <form action="admin.php?a=newnews" enctype="multipart/form-data" method="post"> <input type="hidden" name="process" value="yes" /> <input type="hidden" name="process_b" value="yes" /> <input type="hidden" name="size_limit" value="500" /> <table width="500" border="0">   <? for ($i=1;$i<=$num_news;$i++) {   echo '<tr>     <td width="151"><strong>Article #'.$i.'</strong></td>     <td width="442"></td>   </tr>   <tr>     <td>Upload Pic:</td>     <td><input type="file" name="file' . $i . '"></td>   </tr>   <tr>     <td>Content:</td>     <td><textarea rows=10 cols=40 name="news_content' . $i . '" value="'. $row['content'].'"></textarea></td>   </tr>   <tr>     <td>Type:</td>     <td><select name="type' . $i . '" id="type"> <option>Choose one</option> <option value="house">House</option> <option value="hip hop">Hip Hop</option> <option value="both">Both</option></br></br></td>   </tr>';   }?>   </table> <br /> <input type="submit" value="Submit News" /> </form> </div> [/code]
  4. I already tried that and it didn't work, that's why i tried the 2nd echo ;)
  5. Hey guys, I have an echo that displays form elements, 1 of them is a textarea and I need the value to be something that's fetched from my DB so this is what I did but it's now working, keeps giving me an error [code] <? for ($i=1;$i<=$num_news;$i++) {   echo '<tr>     <td width="151"><strong>Article #'.$i.'</strong></td>     <td width="442"></td>   </tr>   <tr>     <td>Upload Pic:</td>     <td><input type="file" name="file' . $i . '"></td>   </tr>   <tr>     <td>Content:</td>     <td><textarea rows=10 cols=40 name="news_content' . $i . '" value="'. echo $row['content'];.'"></textarea></td>   </tr>   <tr>     <td>Type:</td>     <td><select name="type' . $i . '" id="type"> <option>Choose one</option> <option value="house">House</option> <option value="hip hop">Hip Hop</option> <option value="both">Both</option></br></br></td>   </tr>';   }?> [/code] I tried it without the second echo and even though the script worked it didn't display anything. I tried using the echo $row['content'] alone and it worked perfectly so I know that's not the problem. Any ideas how can I display the textarea value?
  6. can you give me an example? I tried reading on BIT fields but I'm not sure how to use it in m case. What I'm trying to do is that when a user goes on a certain page, he doesn't see the categories that he was banned from. If he got banned from a moderator 3 times he's automaticaly on the block list
  7. ok I got it to display something now my problem is that i display all the nights that have info, it doesn't matter what club is chosen. [code] echo '<SCRIPT language=JavaScript type=text/javascript> '; echo 'var store = new Array();'; for ($i=0; $i<$numRows; $i++){ //for each item $js_array = ""; $sql = 'SELECT * FROM clubnights'; // I know I have to add a WHERE here $result = mysql_query($sql) or die (mysql_errno().": select ".mysql_error()."<BR>" . $sql); while ($row = mysql_fetch_array($result)) { $js_array .= "'" . $row['night'] . "','" . $row['night'] . "',"; } $js_array = rtrim( $js_array , ","); // trim final comma echo 'store['.$i.'] = new Array('; // start javascript array echo $js_array . "); "; } // end for echo '</SCRIPT>'; [/code] I know I have to add a WHERE not sure how, since the value it gets from the first dropdown is the ID of the club table, but that idea doesn't match the ID in the clubnights table. Any ideas what I could do? *edit* actually forget what I said it doesn't work at all  :( I'm really lost here...
  8. hey guys, I'm trying to find the best way I can do this, right now an admin can ban user from using categories and a moderator can do the same thing but what 'm trying to figure out is what would be the best way to check if a user has been banned from a category. Once a user has been banned 3 times from a moderator he's moved to the block_list and can't access his account anymore. But an admin can ban a user from categories as many times as he wishes without having the user being moved to the block list. What would be the best way of doing this? Making 2 seperate tables one for the bans from the admin and the other for the bans from the moderators? Or adding 2 rows in the user table? I'm thinking the seperate tables but how do I validate the user, is there a way to check 2 different tables just by using a single line?
  9. wrong forum, try your luck here http://www.phpfreaks.com/forums/index.php/board,6.0.html ;)
  10. actually my solution isn't good, if a user selects a contest but doesn't submit the 2nd form, when he chooses another contest it will still keep the name of the first contest stored in the session.... Does anyone know a workaround for this?
  11. nevermind I just added [code] if(isset($_SESSION['contest'])) { } else { $_SESSION['contest'] = $_POST['dname']; } [/code] and added an unset after the form gets submitted so it's working perfectly now. Just out of curiosity is there a better way of doing this?
  12. aha that worked even after the 2nd form got submitted! so what do I have to do to make it work now? I really need to get the name of the contest from a dropdown and store it in a session
  13. yup it works perfectly it outputs 'test3' but it's when I submit that form that the session gets destroyed. [quote author=corbin link=topic=99831.msg393342#msg393342 date=1152313384] in the second form... or which ever one youre having trouble with, at the very top of the page try putting session_start(); echo $_SESSION['contest']; and see if it echos anything [/quote]
  14. the second condition comes from the first form [code] <div id="article"> <form action="admin.php?a=editcont" method="post"> <input type="hidden" name="process" value="yes" /> <table border="0"> <tr>         <td>Contest:</td>         <td><select name="dname" id="dname">             <option>Choose one</option>             <?php $sql='SELECT * FROM '.$prefix.'contests'; $req=mysql_query($sql) or die(query_error()); while($data = mysql_fetch_assoc($req)) { echo "<option value='" . stripslashes($data['name']) . "'>" .$data['name'] . "</option>"; } ?>           </select></td> </tr> </table> <br /> <input type="submit" value="Edit Contest" /> </form> </div>[/code] and that works perfectly so let's say you choose Contest 01 if I echo $_SESSION['contest'] it will output Contest 01 but as soon as the second form is submitted that session outputs nothing....
  15. that didn't change anything.... $_SESSION['contest'] still becomes empty
  16. hey guys, I seem to be having problems with my sessions, for some reason they're not being stored for very long... so here's what i got [code] <?php session_start(); //.... case "editcont":       $process=$_POST['process'];         if ($process == "yes") {         $process_b=$_POST['process_b'];         $_SESSION['contest']=$_POST['dname'];           if ($process_b == "yes") {           $new_name=$_POST['contest'];   $new_description=$_POST['description'];   $month=$_POST['month'];   $day=$_POST['day'];   $year=$_POST['year'];   $new_date=$month.'-'.$day.'-'.$year;   $new_question=$_POST['question'];   $new_answer=$_POST['answer'];                                     print $_SESSION['contest'];  //outputs nothing mysql_query("UPDATE ".$prefix."contests SET name='$new_name',description='$new_description',end_date='$new_date',question='$new_question',answer='$new_answer' WHERE name='".$_SESSION['contest']."'") or die(query_error()); $tmpl->add_template("editcont_success");           }           else {           $result=mysql_query("SELECT * FROM ".$prefix."contests WHERE name='".$_SESSION['contest']."'") or die(query_error()); //session works perfectly here           $row=mysql_fetch_array($result);             if ($row['id'] != "") {             $tmpl->add_template("editcont_form2");             }             else {             $tmpl->add_template("username_no");             }           }         }         else {         $tmpl->add_template("editcont_form1");         }            break; ?> [/code] everything works perfectly until the 2nd form is submitted for some reason the session gets destroyed.... I really don't have a clue why... here's the 2nd form. [code] <?php $result=mysql_query("SELECT * FROM ".$prefix."contests WHERE name='". $_SESSION['contest'] ."'") or die(query_error()); $row=mysql_fetch_array($result); $path = "img/contests/" . $_SESSION['contest'] ."/"; $dir = $path . "thumbnails/"; $aNames = array(); if (is_dir($dir)) {   if ($dh = opendir($dir)) {       while (($file_names = readdir($dh)) !== false) {           if ($file_names != "." && $file_names != "..") {   array_push($aNames,$file_names);   }       }       closedir($dh);   } } $numFiles = count($aNames); if ($numFiles == 0) { $file_names = "no_thumb.jpg"; array_push($aNames,$file_names); } ?> <script type="text/javascript"> function writeMonthOptions() {   var theMonth;   var monthCounter;   var numMonth;   var theDate = new Date();   var month=new Array(12)   month[0]="January"   month[1]="February"   month[2]="March"   month[3]="April"   month[4]="May"   month[5]="June"   month[6]="July"   month[7]="August"   month[8]="September"   month[9]="October"   month[10]="November"   month[11]="December"    for (monthCounter = 0; monthCounter < 12; monthCounter++)   {     numMonth = monthCounter + 1; theMonth = month[monthCounter];     if (numMonth < 10 ) {   numMonth = '0' + numMonth; } document.write('<OPTION value=' + numMonth + '>' + theMonth);   } } function writeDay() {   var dayCounter;   var numDay;   //numDay = dayCounter;   for (dayCounter = 1; dayCounter <= 31; dayCounter++)   {     if (dayCounter < 10) {   numDay = '0' + dayCounter; } else {    numDay = dayCounter; } document.write('<OPTION value=' + numDay + '>' + dayCounter);   } } </script> <div id="article"> <form action="admin.php?a=editcont" method="post" enctype="multipart/form-data" name="form" id="form"> <input type="hidden" name="process" value="yes" /> <input type="hidden" name="process_b" value="yes" /> <input type="hidden" name="size_limit" value="500" />     <input name="size_limit" type="hidden" id="size_limit" value="500" />     <table width="603" border="0">       <tr>         <td colspan="2">&nbsp;</td>       </tr>       <tr>         <td width="151">Contest:</td>         <td width="442"><input name="contest" type="text" id="contest" value="<?php echo $row['name']; ?>"/></td>       </tr>       <tr>         <td>Description:</td>         <td><textarea name="description" cols="50" rows="10" id="description"><?php echo $row['description']; ?></textarea></td>       </tr>       <tr>         <td>End Date:</td>         <td><select name="month" id="month">             <option>Month</option>             <script type="text/javascript">writeMonthOptions();</script>           </select> <select name="day" id="day">             <option>Day</option>             <script type="text/javascript">writeDay();</script>           </select>           <select name="year" id="year">             <option>Year</option>             <? $now = date('y'); for ($i=1; $i<=6; $now++) { if(strlen($now) ==1 ) { $now = '0'.$now; } echo '<option value= "'.$now.'">20'.$now.'</option>'; $i++; } ?>           </select></td>       </tr>       <tr>         <td>Images:</td>         <td><? echo '<table border="0"> <table width="1%" border="0">             <tr>'; for ($i =0; $i <= $numFiles--; $i++) {   echo '<td> <a href="' . $path . ''. $aNames[$i].'" target="_blank"> <img src="' . $dir . '' . $aNames[$i] . '" alt="' . $aNames[$i] .'" /></a> </td>'; } echo '</tr>           </table>';?>           <table width="1%" border="0">             <tr>               <td>&nbsp;</td>               <td>&nbsp;</td>             </tr>           </table></td>       </tr>       <tr>         <td>Add  Image  :</td>         <td><input name="file1" type="file" id="file1" /></td>       </tr>       <tr>         <td>Security Question  :</td>         <td><input name="question" type="text" id="question" value="<?php echo $row['question']; ?>"></td>       </tr>       <tr>         <td>Security Answer :</td>         <td><input name="answer" type="text" id="answer" value="<?php echo $row['answer']; ?>" /></td>       </tr>     </table> <input type="submit" value="Edit <?php echo $row['name']; ?>"/> <label> <input type="reset" name="Reset" value="Reset" /> </label> </form> </div>[/code] any help would be greatly appreciated!
  17. thanks for the link llitebearer works perfectly now. I got another question though, does anyone know how I can add a delete button so that when it gets clicked the pic gets deleted? This is what I tried so far [code]<? echo '<script> function del() { var delimgfinal = confirm("Are you sure you want to delete, ' . $aNames[$i] . '?") if(delimgfinal == true) { unlink($path.$aNames[$i]);                 unlink($dir.$aNames[$i]); } else { } } </script>'?> //...... <? for ($i =0; $i <= $numFiles--; $i++) { echo '<tr><td> <a href="' . $path . ''. $aNames[$i].'" target="_blank"> <img src="' . $dir . '' . $aNames[$i] . '" alt="' . $aNames[$i] .'" /></a> </td></tr><input type="button" onclick="del()" value="Delete Image" />'; } ?> [/code] but that's not working.... any ideas why it's not working?
  18. so what would you suggest  ;) $numFiles is declared right under the first part, just forgot to copy paste it... [code] $numFiles = count($aNames); [/code] and the first echo was just a test, forgot to use the []  :P
  19. hey guys, I'm trying to get a script to read the contents of a directory, store the file names in an array and then displaying those files. So far I got the 2 first parts to work like a charm but I'm having trouble displaying the elements of the array. Here's what I got so far. [code] //this part works perfectly $dir = "img/events/" . $name . "/thumbnails/"; $aNames = array(); if (is_dir($dir)) {    if ($dh = opendir($dir)) {        while (($file_names = readdir($dh)) !== false) {            if ($file_names != "." && $file_names != "..") {    array_push($aNames,$file_names);    }        }        closedir($dh);    } } //this part doesn't for ($i ='0'; $i <= $numFiles; $i++) {   echo array_values($aNames);   echo '<tr><td> <img src="' . $dir . '' . $aNames[i] . '" alt="' . $aNames[i] .'" /> </td></tr>'; }[/code] the second part only displays the path but the array returns nothing, If echo just the array for instance echo $aNames[0]; it does return a value. Any ideas what I can do?
  20. Hi daniel, I couldn't try this before because I was moving out and didn't have internet yet.. I jus gave it a shot but was unsucessful. I keep getting an error in IE saying Line: 42 Char: 10 Error: 'length' is null or not an object Code: 0 Do you think it's because not all of the elements have a subcategory?? What needs to be changed in the script to fix that? I tried changing a few things but it didn't really help. [code]<?php $sql = 'SELECT * FROM clubs'; $result = mysql_query($sql) or die (mysql_errno().": select ".mysql_error()."<BR>" . $sql); $numRows = mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $select1_drop .= '<OPTION VALUE="' . $row['name'] . '">' . $row['name'] . '</OPTION>'; } echo '<SCRIPT language=JavaScript type=text/javascript> '; echo 'var store = new Array();'; for ($i=0; $i<$numRows; $i++){ //for each item $js_array = ""; $sql = 'SELECT * FROM clubnights'; $result = mysql_query($sql) or die (mysql_errno().": select ".mysql_error()."<BR>" . $sql); while ($row = mysql_fetch_array($result)) { $js_array .= "'" . $row['night'] . "','" . $row['night'] . "',"; } $js_array = rtrim( $js_array , ","); // trim final comma echo 'store['.$i.'] = new Array('; // start javascript array echo $js_array . "); "; } // end for echo '</SCRIPT>'; ?> <SCRIPT language=JavaScript type=text/javascript> <!-- Begin /* Execute init() function */ window.onload = initialize; function initialize () { if (self.init) self.init(); } function init() { optionTest = true; lgth = document.forms[0].nightDrop.options.length - 1; document.forms[0].nightDrop.options[lgth] = null; if (document.forms[0].nightDrop.options[lgth]) optionTest = false; } function populate() { if (!optionTest) return; var box = document.forms[0].clubDrop; var number = box.options[box.selectedIndex].value; if (!number) return; var list = store[number]; var box2 = document.forms[0].nightDrop; box2.options.length = 0; for(i=0;i<list.length;i+=2) { box2.options[i/2] = new Option(list[i],list[i+1]); } } //  End --> </SCRIPT> <div id="article"> <form action="admin.php?a=editclubnight" method="post" name="form" id="form"> <input type="hidden" name="process" value="yes" />     <table border="0">       <tr>         <td>Club:</td>         <td><select name="clubDrop" id="club" onchange="populate()">           <option>Choose one</option>           <?php echo $select1_drop; ?>         </select></td>       </tr>       <tr>         <td>Night:</td>         <td><select name="nightDrop" id="night">           <OPTION VALUE="">- - - - - - - - - - - - - - -</OPTION> <option>your browser can't handle this script</option>         </select></td>       </tr>     </table> <br /> <input type="submit" value="Edit Night" /> </form> </div>[/code] I'm not sure what to do, I have a table that contains all of the clubs and another table that contains all of the nights and infos. So if I create a night for a club then in 'clubnights' there will be the name of the night, for instance friday and the club name. so the clubnights table looks like ID | Club     | Night |.... 1  | System | Friday |.... 2  | System | Saturday |... etc Right now when I select a club in the dropdown, the second dropdown becomes blank
  21. that's my problem though I can't add the elements manually, they have to be retrieved from a DB since they're added/removed from an admin panel....
  22. Hey guys, I've been trying to populate a dropdown box dynamically depending on what the user selected in another dropdown. What I want it to do is the user selects an element from the first dropdown, the scripts checks the database and if there's one or more sub-categories associated to that element it displays them in the second dropdown. But I don't want the page to refresh itself for that to happen. This is what I've done so far [code] <script language="JavaScript"> function check() { var selObj = document.getElementById('night'); if (document.getElementById('club').value != '' ) { <?php  $checkClub = $_POST["club"]; $result=mysql_query("SELECT * FROM clubnights WHERE club='". $checkClub ."'") or die(query_error()); $row=mysql_fetch_array($result); ?>         } } </script> <div id="article"> <form action="admin.php?a=editclubnight" method="post" name="form" id="form"> <input type="hidden" name="process" value="yes" />     <table border="0">       <tr>         <td>Club:</td>         <td><select name="club" id="club" onchange="check()">           <option>Choose one</option>           <?php $sql='SELECT * FROM clubs'; $req=mysql_query($sql) or die(query_error()); while($data = mysql_fetch_assoc($req)) { echo '<option value="'.$data['name'].'">'.$data['name'].'</option>'; } ?>         </select></td>       </tr>       <tr>         <td>Night:</td>         <td><select name="night" id="night">           <option>Choose one</option>           <?php while($row = mysql_fetch_assoc($result)) { echo '<option value="'.$row['night'].'">'.$data['night'].'</option>';   }?>         </select></td>       </tr>     </table> <br /> <input type="submit" value="Edit Night" /> </form> </div>[/code] so I'm really not sure what to do next... any help would be greatly appreciated!
  23. alright tried everything I can think of but still can't get this to work.... can anyone please help me out? Would really appreciate it
  24. got an idea about what I can do Ken? I've been trying to figure this out but haven't been succesful so far...
  25. [!--quoteo(post=382662:date=Jun 11 2006, 05:53 PM:name=waverider303)--][div class=\'quotetop\']QUOTE(waverider303 @ Jun 11 2006, 05:53 PM) [snapback]382662[/snapback][/div][div class=\'quotemain\'][!--quotec--] I was wondering if PHP is the coding language to use to create a database to book events. Example of what I mean is when people book flights they type the info and click book an instantly it shows up and where they are booked. [/quote] you need a combination of php and mysql here's a MySQL tutorial [a href=\"http://www.phpfreaks.com/tutorials/33/0.php\" target=\"_blank\"]http://www.phpfreaks.com/tutorials/33/0.php[/a]
×
×
  • 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.