Jump to content

JamesThePanda

Members
  • Posts

    133
  • Joined

  • Last visited

Posts posted by JamesThePanda

  1. array (james, john, pingo, adam, john, james, pingo, barney, pingo, );

     

    I was wondering if there is an in-built PHP function that would list all the names once.

     

    IE

     

    james

    john

    pingo

    adam

    barney

     

    not :

     

    james

    john

    pingo

    adam

    john

    james

    pingo

    barney

    pingo

     

    I have been googling this and cant seem to fnd what I want, having a hard time explain it in a google search term.

     

    Thanks

     

    James

  2. $rowNo = 0;
    while($res = mysql_fetch_array($result))
    {
    $rowNo++; //Increment Row Number
    $date = date("D, j M, Y", $res['time']);
    $center = strtoupper($res['center']);
    
    
    if($res['approval'] == "Yes") {
    $approvalText = "Approved":
    $approvalColor = '#CDE861';
    } else if($res['approval'] == "No") {
    $approvalText = "Rejected":
    $approvalColor = '#F28598';
    } else {
    $approvalText = "Pending":
    $approvalColor = '#EDA553';
    }?>
    
    
    <tr align='center' bgcolor='<?php {$approvalColor} \n ?>'>
    <td style='color:black;'><?php {$rowNo}; ?></td>
    <td style='color:black;'><?php {$res['randid']}; ?></td>
    <td style='color:black;'><?php {$center}; ?></td>
    <td style='color:black;'><?php {$res['customer_name']}; ?></td>
    <td style='color:black;'><?php {$res['home_phone']}; ?></td>
    <td style='color:black;'><?php {$date}; ?></td>
    <td><?php {$approvalText}; ?></td>
    <td><a href ="view.php?id=<?php {$res['id']}; ?>"><center>Click to View </center></a></td><br />
    
    
    //And continue on for other rows
    
    
    </tr><br /><?php
    }
    

     

    sorry but thats the better way to right it instead of using all the echo codes

  3. the process you need to go through is input the the $_POST fields into an array.

     

    $varible1 = $_POST['first_name'];

    $varible2 = $_POST['last_name'];

    $varible3 = $_POST['company'];

    $varible4 = $_POST['email'];

     

    $array = array($varible1, $varible2, $varible3, $varible4,);

     

    foreach($array as $B){

     

    $c[] = str_replace(' ', '_', $B);

     

     

    }

     

     

    this will gie you a formatted array.

  4. Hi thanks for that

     

    I replace that li with your code,

     

    Now im getting an error on line 20

     

    it makes no sence :(

     

    <?php
    
    $con = mysql_connect("localhost","root","");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    if (!isset($_POST['id'])){
    mysql_select_db("product", $con);
    
    $result = mysql_query("SELECT * FROM  product2");
    
    echo'<form method="post" action="pro.php">';
    while($row = mysql_fetch_array($result))
      {
    echo '<tr><td><input type="checkbox" name="uid[]" value="'.$row['ID'].'" /></td><td>"'.$row['filename'].'"</td><td>"'.$row['title'].'"</tr>';
    }
    
    echo '<input type="submit" name="formSubmit" value="Submit" /></form>';
    ?>

     

    Thanks

     

    James

  5. ok here is the new "improved" code.

     

    Also I'm getting a parse error on line 16

     

     

    <?php
    
    $con = mysql_connect("localhost","root","");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    if (!isset($_POST['id'])){
    mysql_select_db("product", $con);
    
    $result = mysql_query("SELECT * FROM  product2");
    
    echo'<form method="post" action="pro.php">';
    while($row = mysql_fetch_array($result))
      {
      echo '<tr><td><input type="checkbox" name="uid[]" value=".$row['ID']." /></td><td>".$row['filename']."</td><td>".$row['title']."</tr>';
      }
    
    echo '<input type="submit" name="formSubmit" value="Submit" /></form>';
    ?>

  6. ok this is what I have but for some reason its stoped working geting a parse error on the last line  :wtf:

     

     

    <?php
    
    $con = mysql_connect("localhost","root","");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    if (!isset($_POST['id'])){
    mysql_select_db("product", $con);
    
    $result = mysql_query("SELECT * FROM  product2");
    
    echo'<form method="post" action="pro.php">';
    while($row = mysql_fetch_array($result))
      {
      echo "<tr><td><input type=\"checkbox\" name=\"uid[]\" value=\"".$row['ID']."\" /></td><td>".$row['filename'] . "</td><td> " . $row['title']. "</tr> ";
      }
    
    echo '<input type=\"submit\" name=\"formSubmit\" value=\"Submit\" />';
    echo '</form>';
    mysql_close($con);
    ?>

  7. Hi

     

    I cant understand why this code isnt echoing the results.

     

    $ids = $_POST['uid'];
    
    $con = mysql_connect("localhost","root","");
    
    mysql_select_db("product", $con);
    
    $sqlout = mysql_query("SELECT * FROM product2 WHERE 'ID' IN ('$ids')");
    
    while ($sqlres = mysql_fetch_assoc($sqlout))
      {
      echo $sqlres['filename'] . " " . $sqlres['title'];
      }
    
    mysql_close($con);
    
    

     

     

    Anyone got any ideas?

     

    Thanks

     

    James

  8. Hi

    I made some adjustments to the code,

     

    $ids = $_POST['uid'];

     

    $con = mysql_connect("localhost","root","");

     

    mysql_select_db("product", $con);

     

    $sqlout = mysql_query("SELECT * FROM `product2` WHERE `ID` IN ('$ids')");

     

    while ($sqlres = mysql_fetch_assoc($sqlout))

      {

      echo $sqlres['filename'] . " " . $sqlres['title'];

      }

     

    mysql_close($con);

     

     

    Im wondering why it isnt echoing the results?

     

    Any thoughts

  9. Hi

     

    I have been getting this error.

     

    mysql_fetch_array() expects parameter 1 to be resource, boolean given

     

    Its driving me mad I know its something really simple. Can anyone see what it is?

     

    mysql_select_db("product", $con);
    
    $sqlout = mysql_query("SELECT * FROM 'tblt' WHERE 'UID' =('$ids')");
    
    while($sqlres = mysql_fetch_array($sqlout))

     

     

    Thanks

     

    James

  10. Hi Cunoodle

     

    For some reason its starte working now I been playing wit it for a hour or so. I think the problem was i was getting the data from a file and looking for several tags all at once.

    I just split them up a bit and thats seems to work :)

     

    Thanks SO much for you help

     

    James

     

  11. snip echo out fine

     

    in regards to finding just "<div id=" there several div tages in the code would it end up giving the position off all of them.

     

    thanks

     

    James 

  12. Hi

    Im having a problem finding the posistion of a div tag I tried this piece of code

     

    $fpos= strpos($snip, "<div id=\"footer\">")

     

    Then this piece

     

    $fpos= strpos($snip, "<div id="footer">")

     

    The $snip is the entire html document

     

    I thought maybe the \ might be causeing problem but without it

     

    Then i tried this

     

    any suggestions guys

     

    Thanks

     

    James

  13. Hi

     

    Im just working on a wordpress pugin at the moment and Iw as trying out this piece of code

     

    $mylink = $wpdb->get_row("SELECT * FROM $wpdb->testtable WHERE id = 1");

     

    echo $mylink->id ;

     

    there is data in the table there is an id equal to one but it not coming up with anything

     

    I tried it with anouther pable and it works fine I can for example

     

    $mylink = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE id = 1");

     

    echo $mylink->post_content ;

     

    That comes up fine with the data

     

    But the first one I dont know why its not working

     

     

    can anyone help

     

     

    Thanks

     

    James

×
×
  • 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.