Jump to content

moran1409

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Posts posted by moran1409

  1. hello i have a mysql table and i want to display each row in a different page with an added condition, the code:

    	if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
      $start_from = $page-1; 
    
    	$qry="SELECT * FROM ordering WHERE userid='$page' AND email='$email' LIMIT 0,1";
    	$result = mysql_query($qry);
    	while($row = mysql_fetch_array($result)){
    
    	echo     "<div dir='rtl' charset='utf8'><h2>"," hover cam: ",$row['hover_camera'],
    	"<br> stills: ",$row['stills'],
    	"<br> video_photographers: ",$row['video_photographers'],
    	"<br> increase: ",$row['increase'],
    	"<br> video_edit: ",$row['video_edit'],
    	"<br> digital_album: ",$row['digital_album'],
    	"<br> photo_album: ",$row['photo_album'],
    	"<br> small_digital_album: ",$row['small_digital_album'],
    	"<br> video_clip: ",$row['video_clip'],
    	"<br> magnets: ",$row['magnets'],
    	"<br> comments: ",$row['comments'],
    	"<br> date: ",$row['date'],
    	"<br><br></h2></div>";	
    
    }
    	$sql = "SELECT COUNT(userid) FROM ordering"; 
    	$result = mysql_query($sql,$link); 
    	$row2 = mysql_fetch_row($result); 
    	$total_records = $row2[0]; 
    	$total_pages = $total_records ; 
    
    for ($i=1; $i<=$total_pages; $i++) { 
                echo "<a href='myorders.php?page=".$i."'>".$i."</a> "; 
    }; 

     

    the table is as so:

    CREATE TABLE IF NOT EXISTS `ordering` (
      `userid` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `hover_camera` varchar(10) DEFAULT NULL,
      `stills` int(5) NOT NULL,
      `video_photographers` int(5) NOT NULL,
      `increase` int(5) NOT NULL,
      `video_edit` varchar(10) NOT NULL,
      `digital_album` varchar(10) DEFAULT NULL,
      `photo_album` varchar(10) DEFAULT NULL,
      `small_digital_album` varchar(20) DEFAULT NULL,
      `video_clip` varchar(10) DEFAULT NULL,
      `magnets` int(10) NOT NULL,
      `comments` text NOT NULL,
      `date` date NOT NULL,
      `fname` varchar(100) NOT NULL,
      `email` varchar(100) NOT NULL,
      PRIMARY KEY (`userid`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

     

    now to the problem: this code displays all the userid as page numbers however, the email condition is good only for part of the rows

    it's a little hard to explain, i'll try an example: suppose the email '1@1.com' is at rows 22,25 and 30 my code displays 30 page numbers and page 22 is user 22, page 25 is user 25 etc. what i want is to display only the page numbers of  the pages with the conditional email, and if possible to display them as 1,2,3 instead of 22,25,30

  2. hello all, i have a php form with multiple submits (one calculates price, one checks date and one submits the form and the data to mysql database)

    when i hit calculate price, for example, the function works fine but all the fields are cleared and i would like for all the input to remain as the user sent.

    here is part of the code (the form):

    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    
    <fieldset>
    <legend ><span><a>video</span></a></legend>
    <ol>
    <li>
    <label for="hover_camera">hover camera</label>
    <input id="hover_camera" type="radio" name="hover_camera" value="yes" /><b>yes</b>
    <input id="hover_camera" type="radio" name="hover_camera" value="no"  /><b>no</b>
    </li>
    <li>
    <label for="video_photographers">video photographers</label>
    <input id="video_photographers" type="text" name="video_photographers" maxlength="1" size="1"/>
    </li>
    <li>
    <label for="video_edit">video edit</label>
    <input id="video_edit" type="radio" name="video_edit" value="short" /><b>short</b>
    <input id="video_edit" type="radio" name="video_edit" value="long" /><b>long</b>
    </li>
    <li>
    <label for="video_clip">video clip</label>
         <select name="video_clip">
             <option value="no">no</option>
             <option value="regular">regular</option>
    	 <option value="staged">staged</option>
          </select>
    </li>
    </ol>
    </fieldset><br />
    
    <fieldset align="right">  
        <legend><span><a>stills</span></a></legend> 
    <ol>
    <li>
    <label for="stills">stills</label>
    <input id="stills" type="text" name="stills" maxlength="1" size="1"  />
    </li>
    <li>
    <label for="increase">increase amount</label>
    <input id="increase" type="text" name="increase" maxlength="4" size="1" />
    </li>
    <li>
    <label for="magnets">magnets</label>
    <input id="magnets" type="text" name="magnets" maxlength="4" size="1" />
    </ol>
    </fieldset><br />
    
    <fieldset align="right">  
        <legend><span><a>albums</span></a></legend> 
    <ol>
    <li>
    <label for="digital_album">digital album</label>
    <input id="digital_album" type="radio" name="digital_album" value="yes" /><b>yes</b>
    <input id="digital_album" type="radio" name="digital_album" value="no" /><b>no</b>
    </li>
    <li>
    <label for="photo_album">photo album</label>
    <input id="photo_album" type="radio" name="photo_album" value="yes" /><b>yes</b>
    <input id="photo_album" type="radio" name="photo_album" value="no" /><b>no</b>
    </li>
    <li>
    <label for="small_digital_album">small digital album</label>
    <input id="small_digital_album" type="radio" name="small_digital_album" value="yes" /><b>yes</b>
    <input id="small_digital_album" type="radio" name="small_digital_album" value="no" /><b>no</b>	
    </li>
    </ol>
    </fieldset><br />
    
    <fieldset align="right">
    <ol>
    <li>
    <label for="comments">comments</label>																																																																																																																				
    <textarea id="comments" name="comments"></textarea><br /><br />
    </li>
    <li>
    <label for="price">price</label>
     <td><input type="submit" id = "price" name="price" value="calculate price" /></td>
    </li>
    </ol>
    </fieldset><br />
    
    
    <fieldset align="right">  
        <legend><span><a>choose date</span></a></legend> 
    <ol>
    <li>
    
    
    
          <input type="submit" id="isavailable" name="isavailable" value="isavailable"  />
      </li>
      </ol>
      </fieldset>
      
      	<fieldset class="submit">
    <ol>
    <li>
    <input class="submit" type="submit" id="submit" name="submit" value="done!" />    <input class="submit" type="reset" id="reset" name="reset" value="reset" />
    </li>
    </ol>
    </fieldset>  
      
    </form>

     

    thanks for the help

  3. hello all,

    i want to display each row from mysql table in a different page using this code:

    		<?
    	require_once('config.php');
    //Connect to mysql server
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if(!$link) {
    	die("can't connect: " . mysql_error());
    }
    
    $db = mysql_select_db(DB_DATABASE);
    if(!$db) {
    	die("can't select database");
    }
    mysql_query("SET NAMES 'hebrew'");
    //mysql_set_charset('utf8',$link);
    
    if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
      $start_from = $page-1; 
    
    	$qry='SELECT * FROM ordering limit 0, 1';
    	$result = mysql_query($qry);
    	while($row = mysql_fetch_array($result)){
    
    	echo     "<div dir='rtl' charset='utf8'><h2>"," hover cam: ",$row['hover_camera'],
    	"<br> stills: ",$row['stills'],
    	"<br> video_photographers: ",$row['video_photographers'],
    	"<br> increase: ",$row['increase'],
    	"<br> video_edit: ",$row['video_edit'],
    	"<br> digital_album: ",$row['digital_album'],
    	"<br> photo_album: ",$row['photo_album'],
    	"<br> small_digital_album: ",$row['small_digital_album'],
    	"<br> video_clip: ",$row['video_clip'],
    	"<br> magnets: ",$row['magnets'],
    	"<br> comments: ",$row['comments'],
    	"<br> date: ",$row['date'],
    	"<br><br></h2></div>";	
    
    }
    	$sql = "SELECT COUNT(userid) FROM ordering"; 
    	$result = mysql_query($sql,$link); 
    	$row2 = mysql_fetch_row($result); 
    	$total_records = $row2[0]; 
    	$total_pages = $total_records ; 
    
    for ($i=1; $i<=$total_pages; $i++) { 
                echo "<a href='table.php?page=".$i."'>".$i."</a> "; 
    }; 
    
    	?>

     

    this is the table:

    CREATE TABLE IF NOT EXISTS `ordering` (
    `userid` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `hover_camera` varchar(10) DEFAULT NULL,
    `stills` int(5) NOT NULL,
    `video_photographers` int(5) NOT NULL,
    `increase` int(5) NOT NULL,
    `video_edit` varchar(10) NOT NULL,
    `digital_album` varchar(10) DEFAULT NULL,
    `photo_album` varchar(10) DEFAULT NULL,
    `small_digital_album` varchar(20) DEFAULT NULL,
    `video_clip` varchar(10) DEFAULT NULL,
    `magnets` int(10) NOT NULL,
    `comments` text NOT NULL,
    `date` date NOT NULL,
    PRIMARY KEY (`userid`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;

     

    the problem is that only the first row is displayed no matter which page i choose

    and i want each page to display the row assigned to it (page 15 = row 15 etc...)

    any suggestions?

  4. edit data (changed - but still not working...)

    	include "db.inc.php";
         $order = "UPDATE prices
              SET product='$product',
                  price='$price'
              WHERE
              id_number='$id'";
    mysql_query($order);
    echo $price;

     

     

     

     

    i don't fully understand you both, all i am trying to do is update a mysql table could you tell me which part of the code should i change and how will i do that?

  5. hello all, i am trying to edit a mysql table from the browser using these codes:

     

    edit.php:

    	      include"db.inc.php";//database connection
          $order = "SELECT * FROM prices";
          $result = mysql_query($order);
          while ($row=mysql_fetch_array($result)){
            echo ("<tr><td>$row[id_number]</td>");
            echo ("<td>$row[product]</td>");
            echo ("<td>$row[price]</td>");
            echo ("<td><a href=\"edit_form.php?id=$row[id_number]\">Edit</a></td></tr>");
          }

     

    edit_form.php

    	      <table>
          <?
          include "db.inc.php";//database connection
          $order = "SELECT * FROM prices where id_number='$id'";
          $result = mysql_query($order);
          $row = mysql_fetch_array($result);
          ?>
          <form method="post" action="edit_data.php">
          <input type="hidden" name="id" value="<? echo "$row[id_number]"?>">
            <tr>       
              <td>Product</td>
              <td>
                <input type="text" name="product"
            size="20" value="<? echo "$row[product]"?>">
              </td>
            </tr>
            <tr>
              <td>Price</td>
              <td>
                <input type="text" name="price" size="40"
              value="<? echo "$row[price]"?>">
              </td>
            </tr>
            <tr>
              <td align="right">
                <input type="submit"
              name="submit value" value="Edit">
              </td>
            </tr>
          </form>
          </table>

     

    edit_data.php

    	include "db.inc.php";
    $order = "UPDATE prices SET product='$_POST[product]', price='$_POST[price]' WHERE id_number='$id'";
    mysql_query($order);
    header("location:edit.php");

     

    the table:

    CREATE TABLE IF NOT EXISTS `prices` (

      `id_number` int(3) NOT NULL,

      `product` varchar(30) DEFAULT NULL,

      `price` int(6) DEFAULT NULL,

      PRIMARY KEY (`id_number`)

    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

     

    the data is displayed correctly but i can't change the data...

  6. i get the error for this code:

     

     <?php
                    $news = fopen("test.txt", "rb");
    
                    while (!feof($news) ) {
    
                            $line = fgets($news);
                            $parts = explode('=', $line);
    
                    print $parts[0] . $parts[1]. "<BR>";//line 60!!!
                   
            }
    
            fclose($news);
    
               ?>

     

    i know that this means that the array gets one argument instead of two but i do'nt know how to solve it...

    this code works fine in my localhost but not on the server

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