Jump to content

slenderman

New Members
  • Posts

    6
  • Joined

  • Last visited

slenderman's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. how can i put the $CATEGORY dynamically so that whatever i click on the table it will retrieved in the combo box? (without settng its id to any number like 5 ) <?php $CATEGORY = 5; //from DB table, consider 3 as category id for sample $sql="SELECT tblcourse.id as id, tblcourse.course as course FROM tblcourse"; $result=mysql_query($sql) or die(mysql_error()); $options=""; while ($row=mysql_fetch_assoc($result)) { $id=$row["id"]; $thing=$row["course"]; $isSel = ($CATEGORY == $id)?"selected":''; $options.= " <OPTION VALUE='$id' $isSel>$thing</option>"; } ?> My Combobox form code <select name="cbocourse" style="height:35px; width:280px; background-color:#923227; box-shadow:1px 1px #FFF;color:#C90;" onClick="submitCATEGORY();"> <option value="<?php echo $CATEGORY; ?>"> <?php echo $options;?></option></select>
  2. hey guys i already resolved it however, it is static heres the code <?php $CATEGORY = 5; //from DB table, consider 3 as category id for sample $sql="SELECT tblcourse.id as id, tblcourse.course as course FROM tblcourse"; $result=mysql_query($sql) or die(mysql_error()); $options=""; while ($row=mysql_fetch_assoc($result)) { $id=$row["id"]; $thing=$row["course"]; $isSel = ($CATEGORY == $id)?"selected":''; $options.= " <OPTION VALUE='$id' $isSel>$thing</option>"; } ?> the $CATEGORY is set into 5.. How to set it dynamically so that whatever i selected it populate the combobox with its desired id?
  3. What if i want to have a dynamic item fetched in the database, how to do it? without setting apple, banana etc
  4. do i need to replaced this code <?php $sql = 'SELECT * from tblcourse'; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo '<option value= "' . $row['id']. '">' . $row['course'] . '</option>'; } ?> <?php if(@$courseid ==5){ echo "<option value = '5'>Associate in Computer Technology/option>"; } ?> to that code?
  5. Hi Good day Can someone pls help me regarding with this matter. I have a page for inserting records. And I have a combobox that is fetched through the specific field in database. I also have a table of records, for each row i have an href edit which throws the values to its respective texbox and combobox. THE PROBLEM is that when i click the href edit, the value from a selected row was not displayed from the combobox but with the textboxes it is working except from the combobox which is already fetched from the database. ------> HERE IS THE CODE FOR COMBOBOX <select name="cbocourse" style="height:35px; width:280px; background-color:#923227; box-shadow:1px 1px #FFF;color:#C90;"> <?php $sql = 'SELECT * from tblcourse'; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo '<option value= "' . $row['id']. '">' . $row['course'] . '</option>'; } ?> <?php if(@$courseid ==5){ echo "<option value = '5'>Associate in Computer Technology/option>"; } ?> ------> CODE FOR TABLE OF RECORDS do{ echo '<tr>'; echo "<td><a href = 'fastormain.php?id=".$result['id']."'onclick=\" disableupdatebtn();\"> ". '<center>' . "edit" . '<center>' ."</a></td>"; echo "<td><a href = 'fastormain.php?id=".$result['id']."&action='delete' onClick=\"return confirm('Do you want to delete this record?')\">". '<center>'."delete" . '</center>'."</a></td>"; echo '<td>' . $result['id'] .'</td>'; echo '<td>' . $result['Name'] .'</td>'; echo '<td>' . $result['gender'] .'</td>'; echo '<td>' . $result['birthday'] .'</td>'; echo '<td>' . $result['address'] .'</td>'; echo '<td>' . $result['contactnumber'] .'</td>'; echo '<td>' . $result['course'] .'</td>'; echo '<td>' . $result['branch'] .'</td>'; echo '<td>' . $result['YEAR'] .'</td>'; echo '<td>' . $result['imagename'] .'</td>'; echo '</tr>'; $result= mysql_fetch_assoc($query); } while($result);{ ----------------> AND THE CODE FOR GETTING THE ID IN HREF ?php if(isset($_GET['id'])) { $id = $_GET['id']; $sql = "select * from tblcontestants where id = {$id} limit 1"; $query = @mysql_query($sql,$connection) or die("DATABASE QUERY FAILED"); $result = mysql_fetch_assoc($query); $id=$result['id']; $fname=$result['fname']; $mname=$result['mname']; $lname=$result['lname']; $age=$result['age']; $genderid=$result['genderid']; $birthday=$result['birthday']; $address=$result['address']; $contactnumber=$result['contactnumber']; $courseid=$result['courseid']; $branchid=$result['branchid']; $yearid=$result['yearid']; $imagename=$result['imagename']; }; ?> I KNOW THAT SOMEONE CAN HELP ME! SO PLEASEEEEEEE! IT WILL BE HIGHLY 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.