otixz Posted April 26, 2008 Share Posted April 26, 2008 Hi I have a prob I have 50 courses that I have in my table. I made a table so that users can input enrollees. my prob is that how can I save it? I want to use array to make it save better... here is my code: < ?php //Open and connect to database mysql_connect('localhost','root',''); mysql_selectdb('ereport') or die (mysql_error()); //get all transferred data $full_name= $_SESSION['name'] ; $access = $_SESSION['access']; $date = $_GET['date']; $campus = $_GET['cam']; $act = $_GET['action']; //function list function save_inq() { //mysql_connect('localhost','root',''); //mysql_selectdb('ereport') or die (mysql_error()); $date = $_GET['date']; //echo "select inq_date from tblinquiries where inq_date='$date'"; //1st query for database - locate all courses $save_qry = mysql_query("select inq_date from tblinquiries where inq_date='$date'"); $save_row = mysql_num_rows($save_qry); if($save_row=="0") { echo "wlang record"; } else { echo "save tayo"; //$save=mysql_query("Update tblinquiries set "); } } if($act =="save_inq") { save_inq(); } //date selected minus one day list($d,$m,$y) = explode('/',$date); $new_str = date('d/m/Y',strtotime('-1 day ' . $y. '-' . $m . '-' . $d)); if ($date ==null || $date == " ") { ?> <h2> E-report System <?php echo $campus;?> Campus</h2> <table align="center" border="1" width="80%"> <tr> <td align="left"> <b> SELECT DATE: <input type="text" id="DPC_calendar1" name="calendar1" size="12"> <input type="button" name="go" value="GO" onclick="gregg(this)"></td> </tr> <tr> <td align="left"><BR><B><center>DAILY REPORT OF INQUIRY</td> </tr> </table> <?php } else { ?> <!-- shows the inquiry table --> <input type="hidden" name="hiddendate" id="hiddendate" value="<?php echo $date;?>"> <h2> E-report System <?php echo $campus;?> Campus</h2> <table align="center" border="0" width="80%"> <tr> <td align="left"> <b> SELECT DATE: <input type="text" id="DPC_calendar1" name="calendar1" size="12"> <input type="button" name="go" value="GO" onclick="gregg(this)"></td> </tr> <tr> <td align="left"><BR><B><center>DAILY REPORT OF INQUIRY</td> </tr> <tr> <td align="left"><B><center><I>Edit Data</td> </tr> </table> <br><table align="center" border="1" width="40%"> <tr> <td width="50%"><b><center>COURSE</td> <td width="25%"><center><b> <?php echo $new_str;?> <b> </td> <td width="25%"><center><b><?php echo $date;?> </td> </tr> <?php //1st query for database - locate all courses $qry = mysql_query("select * from tblcourses"); $row = mysql_num_rows($qry); if($row == 0) { echo "no record";?> <?php } else { while($b = mysql_fetch_array($qry)) { $course = $b['coursename']; $initial = $b['initial']; $title = $b['TITLE']; /*2nd query for database - locate all courses and get their total inquiries for the chosen date and the previous date */ $q="select total, (select total from tblinquiries where inq_date='$date' and course='$course') as Total2 from tblinquiries where inq_date='$new_str' and course='$course' "; $query = mysql_query($q); $rows = mysql_num_rows($query); ?> <tr> <?php if($title == "Y") { $course = $b['coursename']; ?> <td bgcolor="#AFEEEE" width="20%"><b><?echo $course;?></td> <td bgcolor="#AFEEEE"></td> <td bgcolor="#AFEEEE" width="5%"></td> <?php }else { $newcourse = str_replace (" ", "", $course); ?> <td width="20%"><?echo $course;?></td> <?php if($rows == "0") { ?> <td><center>--</td> <td><center><input type="text" name="<?php echo $newcourse;?>" value="<?php echo $a['Total2'];?>"></td> <?php } else { while($a= mysql_fetch_array($query)) { ?> <td><center><?php echo $a['total'];?></td> <td><center><input type="text" name="<?php echo $newcourse;?>" value="<?php echo $a['Total2'];?>"></td> <?php } } ?> <?php } ?> </tr> <?php //echo $newcourse ; } ?> <table align="center" border="0" width="40%"> <tr> <td align="right"> <input type="button" name ="save_inq" id ="save_inq" value="SAVE" onclick="save()"> <input type="button" name ="cancel_inq" id ="cancel_inq" value="CANCEL" onclick="cancel()"> </td> </tr> <table> <?php } } ?> Link to comment https://forums.phpfreaks.com/topic/102983-how-can-i-make-an-array-in-php/ Share on other sites More sharing options...
teng84 Posted April 26, 2008 Share Posted April 26, 2008 not quite sure about your problem but you can try <a href="http://www.php.net/manual/en/function.serialize.php">serialize</a> Link to comment https://forums.phpfreaks.com/topic/102983-how-can-i-make-an-array-in-php/#findComment-527571 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.