lecture9 - CPSC431Lecture9 PHP'sMySQLExtension...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CPSC431 Lecture 9
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
PHP's MySQL Extension mysql_num_rows(): number of rows selected $query = "SELECT name FROM product WHERE price > 15.99"; $result = mysql_query($query); echo "There are ".mysql_num_rows($result)." product(s) priced above \ $15.99."; mysql_affected_rows(): number of rows affected $query = "UPDATE product SET price = '39.99' WHERE price='34.99'"; $result = mysql_query($query); echo "There were ".mysql_affected_rows()." product(s) affected. ";
Background image of page 2
PHP's MySQL Extension Deleting data <?php mysql_connect("localhost","webuser","secret"); mysql_select_db("company"); if (isset($_POST['submit'])) { foreach($count=0; $count < count($_POST['rowID']); $count++) { $rowID = $_POST['rowID'][$count]; $query = "DELETE FROM product WHERE rowID='$rowID'"; $result = mysql_query($query); if ((mysql_affected_rows() == 0) || mysql_affected_rows() == -1) { echo "<p>There was a problem deleting some of the selected items.</p>"; exit; } } echo "<p>The selected items were successfully deleted.</p>"; } ?>
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/20/2009 for the course CPSC CPSC431 taught by Professor Prf.wang during the Spring '09 term at CSU Fullerton.

Page1 / 11

lecture9 - CPSC431Lecture9 PHP'sMySQLExtension...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online